ZQuest Classic Coverage Report


Directory: src/
File: src/qst.cpp
Date: 2024-05-02 01:19:50
Exec Total Coverage
Lines: 8944 12566 71.2%
Functions: 97 129 75.2%
Branches: 6279 10728 58.5%

Line Branch Exec Source
1 #include "allegro/file.h"
2 #include "base/util.h"
3 #include "base/version.h"
4 #include "base/zapp.h"
5 #include "base/qrs.h"
6 #include "base/cpool.h"
7 #include "base/autocombo.h"
8 #include "base/packfile.h"
9 #include "base/dmap.h"
10 #include "base/combo.h"
11 #include "base/msgstr.h"
12 #include <filesystem>
13 #include <optional>
14 #include <stdio.h>
15 #include <cstring>
16 #include <string>
17 #include <map>
18 #include <vector>
19 #include <assert.h>
20 #include <fmt/format.h>
21
22
23 #include "metadata/sigs/devsig.h.sig"
24 #include "metadata/sigs/compilersig.h.sig"
25 #include "metadata/versionsig.h"
26 #include "base/zc_alleg.h"
27 #include "base/zdefs.h"
28 #include "base/colors.h"
29 #include "tiles.h"
30 #include "base/zsys.h"
31 #include "qst.h"
32 #include "defdata.h"
33 #include "subscr.h"
34 #include "zc/replay.h"
35 #include "zc/zc_custom.h"
36 #include "sfx.h"
37 #include "md5.h"
38 #include "zinfo.h"
39 #include "zc/ffscript.h"
40 #include "particles.h"
41 #include "dialog/alert.h"
42 #include "base/misctypes.h"
43 #include "base/initdata.h"
44
45 //FFScript FFCore;
46 extern FFScript FFCore;
47 extern ZModule zcm;
48 extern zcmodule moduledata;
49 extern uint8_t __isZQuest;
50 extern sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations;
51 extern particle_list particles;
52 extern void setZScriptVersion(int32_t s_version);
53 //FFSCript FFEngine;
54
55 static bool read_ext_zinfo = false, read_zinfo = false;
56 static bool loadquest_report = false;
57 static char const* loading_qst_name = NULL;
58 static byte loading_qst_num = 0;
59 static byte subscr_mode = ssdtMAX;
60 dword loading_tileset_flags = 0;
61
62 int32_t First[MAX_COMBO_COLS]={0},combo_alistpos[MAX_COMBO_COLS]={0},combo_pool_listpos[MAX_COMBO_COLS]={0},combo_auto_listpos[MAX_COMBO_COLS]={0};
63 map_and_screen map_page[MAX_MAPPAGE_BTNS]= {{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}};
64
65 #ifdef _MSC_VER
66 #define strncasecmp _strnicmp
67 #endif
68
69 #ifndef _AL_MALLOC
70 #define _AL_MALLOC(a) _al_malloc(a)
71 #define _AL_FREE(a) _al_free(a)
72 #endif
73
74 using std::string;
75 using std::pair;
76
77 // extern bool debug;
78 extern int32_t hero_animation_speed; //lower is faster animation
79 extern byte *colordata;
80 //extern byte *tilebuf;
81 extern tiledata *newtilebuf;
82 extern byte *trashbuf;
83 extern itemdata *itemsbuf;
84 extern wpndata *wpnsbuf;
85 extern comboclass *combo_class_buf;
86 extern guydata *guysbuf;
87 extern ZCHEATS zcheats;
88 extern char palnames[MAXLEVELS][17];
89 extern char *byte_conversion(int32_t number, int32_t format);
90 extern char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2);
91 string zScript;
92 358 std::map<int32_t, script_slot_data > ffcmap;
93 358 std::map<int32_t, script_slot_data > globalmap;
94 358 std::map<int32_t, script_slot_data > genericmap;
95 358 std::map<int32_t, script_slot_data > itemmap;
96 358 std::map<int32_t, script_slot_data > npcmap;
97 358 std::map<int32_t, script_slot_data > ewpnmap;
98 358 std::map<int32_t, script_slot_data > lwpnmap;
99 358 std::map<int32_t, script_slot_data > playermap;
100 358 std::map<int32_t, script_slot_data > dmapmap;
101 358 std::map<int32_t, script_slot_data > screenmap;
102 358 std::map<int32_t, script_slot_data > itemspritemap;
103 358 std::map<int32_t, script_slot_data > comboscriptmap;
104 358 std::map<int32_t, script_slot_data > subscreenmap;
105 void free_newtilebuf();
106 bool combosread=false;
107 bool mapsread=false;
108 bool fixffcs=false;
109 bool fixpolsvoice=false;
110
111 const std::string script_slot_data::DEFAULT_FORMAT = "%s %s";
112 const std::string script_slot_data::INVALID_FORMAT = "%s --%s";
113 const std::string script_slot_data::DISASSEMBLED_FORMAT = "%s ++%s";
114 const std::string script_slot_data::ZASM_FORMAT = "%s ==%s";
115
116 char qstdat_string[2048] = { 0 };
117
118 static zinfo* load_tmp_zi = NULL;
119
120 int32_t memDBGwatch[8]= {0,0,0,0,0,0,0,0}; //So I can monitor memory crap
121 const byte clavio[9]={97,109,111,110,103,117,115,0};
122
123 //enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
124 // qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
125
126 const char *qst_error[] =
127 {
128 "OK","File not found","Invalid quest file",
129 "Version not supported","Obsolete version",
130 "Missing new data" , /* but let it pass in ZQuest */
131 "Internal error occurred", "Invalid password",
132 "Quest title doesn't match saved game", "Save file is for older version of quest; please start new save",
133 "Out of memory", "File Debug Mode", "Canceled", "", "No quest assigned"
134 };
135
136 //for legacy quests -DD
137 enum { ssiBOMB, ssiSWORD, ssiSHIELD, ssiCANDLE, ssiLETTER, ssiPOTION, ssiLETTERPOTION, ssiBOW, ssiARROW, ssiBOWANDARROW, ssiBAIT, ssiRING, ssiBRACELET, ssiMAP,
138 ssiCOMPASS, ssiBOSSKEY, ssiMAGICKEY, ssiBRANG, ssiWAND, ssiRAFT, ssiLADDER, ssiWHISTLE, ssiBOOK, ssiWALLET, ssiSBOMB, ssiHCPIECE, ssiAMULET, ssiFLIPPERS,
139 ssiHOOKSHOT, ssiLENS, ssiHAMMER, ssiBOOTS, ssiDIVINEFIRE, ssiDIVINEESCAPE, ssiDIVINEPROTECTION, ssiQUIVER, ssiBOMBBAG, ssiCBYRNA, ssiROCS, ssiHOVERBOOTS,
140 ssiSPINSCROLL, ssiCROSSSCROLL, ssiQUAKESCROLL, ssiWHISPRING, ssiCHARGERING, ssiPERILSCROLL, ssiWEALTHMEDAL, ssiHEARTRING, ssiMAGICRING, ssiSPINSCROLL2,
141 ssiQUAKESCROLL2, ssiAGONY, ssiSTOMPBOOTS, ssiWHIMSICALRING, ssiPERILRING, ssiMAX
142 };
143
144 static byte deprecated_rules[QUESTRULES_NEW_SIZE];
145
146
147 char *byte_conversion(int32_t number, int32_t format)
148 {
149 static char num_str[40];
150
151 if(format==-1) //auto
152 {
153 format=1; //bytes
154
155 if(number>1024)
156 {
157 format=2; //kilobytes
158 }
159
160 if(number>1024*1024)
161 {
162 format=3; //megabytes
163 }
164
165 if(number>1024*1024*1024)
166 {
167 format=4; //gigabytes (dude, what are you doing?)
168 }
169 }
170
171 switch(format)
172 {
173 case 1: //bytes
174 sprintf(num_str,"%db",number);
175 break;
176
177 case 2: //kilobytes
178 sprintf(num_str,"%.2fk",float(number)/1024);
179 break;
180
181 case 3: //megabytes
182 sprintf(num_str,"%.2fM",float(number)/(1024*1024));
183 break;
184
185 case 4: //gigabytes
186 sprintf(num_str,"%.2fG",float(number)/(1024*1024*1024));
187 break;
188
189 default:
190 abort();
191 break;
192 }
193
194 return num_str;
195 }
196
197 char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2)
198 {
199 static char num_str1[40];
200 static char num_str2[40];
201 static char num_str[80];
202
203 if(format1==-1) //auto
204 {
205 format1=1; //bytes
206
207 if(number1>1024)
208 {
209 format1=2; //kilobytes
210 }
211
212 if(number1>1024*1024)
213 {
214 format1=3; //megabytes
215 }
216
217 if(number1>1024*1024*1024)
218 {
219 format1=4; //gigabytes (dude, what are you doing?)
220 }
221 }
222
223 if(format2==-1) //auto
224 {
225 format2=1; //bytes
226
227 if(number2>1024)
228 {
229 format2=2; //kilobytes
230 }
231
232 if(number2>1024*1024)
233 {
234 format2=3; //megabytes
235 }
236
237 if(number2>1024*1024*1024)
238 {
239 format2=4; //gigabytes (dude, what are you doing?)
240 }
241 }
242
243 switch(format1)
244 {
245 case 1: //bytes
246 sprintf(num_str1,"%db",number1);
247 break;
248
249 case 2: //kilobytes
250 sprintf(num_str1,"%.2fk",float(number1)/1024);
251 break;
252
253 case 3: //megabytes
254 sprintf(num_str1,"%.2fM",float(number1)/(1024*1024));
255 break;
256
257 case 4: //gigabytes
258 sprintf(num_str1,"%.2fG",float(number1)/(1024*1024*1024));
259 break;
260
261 default:
262 abort();
263 break;
264 }
265
266 switch(format2)
267 {
268 case 1: //bytes
269 sprintf(num_str2,"%db",number2);
270 break;
271
272 case 2: //kilobytes
273 sprintf(num_str2,"%.2fk",float(number2)/1024);
274 break;
275
276 case 3: //megabytes
277 sprintf(num_str2,"%.2fM",float(number2)/(1024*1024));
278 break;
279
280 case 4: //gigabytes
281 sprintf(num_str2,"%.2fG",float(number2)/(1024*1024*1024));
282 break;
283
284 default:
285 abort();
286 break;
287 }
288
289 sprintf(num_str, "%s/%s", num_str1, num_str2);
290 return num_str;
291 }
292
293 char *ordinal(int32_t num)
294 {
295 static const char *ending[4] = {"st","nd","rd","th"};
296 static char ord_str[8];
297
298 char *end;
299 int32_t t=(num%100)/10;
300 int32_t n=num%10;
301
302 if(n>=1 && n<4 && t!=1)
303 end = (char *)ending[n-1];
304 else
305 end = (char *)ending[3];
306
307 sprintf(ord_str,"%d%s",num%10000,end);
308 return ord_str;
309 }
310
311 int32_t get_version_and_build(PACKFILE *f, word *version, word *build)
312 {
313 int32_t ret;
314 *version=0;
315 *build=0;
316 byte temp_map_count=map_count;
317 byte temp_midi_flags[MIDIFLAGS_SIZE];
318 memcpy(temp_midi_flags, midi_flags, MIDIFLAGS_SIZE);
319
320 zquestheader tempheader;
321
322 if(!f)
323 {
324 return qe_invalid;
325 }
326
327 ret=readheader(f, &tempheader);
328
329 if(ret)
330 {
331 return ret;
332 }
333
334 map_count=temp_map_count;
335 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
336 *version=tempheader.zelda_version;
337 *build=tempheader.build;
338 return 0;
339 }
340
341
342 bool find_section(PACKFILE *f, int32_t section_id_requested)
343 {
344
345 if(!f)
346 {
347 return false;
348 }
349
350 int32_t section_id_read;
351 bool catchup=false;
352 word dummy;
353 byte tempbyte;
354 char tempbuf[65536];
355
356
357 switch(section_id_requested)
358 {
359 case ID_RULES:
360 case ID_STRINGS:
361 case ID_MISC:
362 case ID_TILES:
363 case ID_COMBOS:
364 case ID_CSETS:
365 case ID_MAPS:
366 case ID_DMAPS:
367 case ID_DOORS:
368 case ID_ITEMS:
369 case ID_WEAPONS:
370 case ID_COLORS:
371 case ID_ICONS:
372 case ID_INITDATA:
373 case ID_GUYS:
374 case ID_MIDIS:
375 case ID_CHEATS:
376 break;
377
378 default:
379 al_trace("Bad section requested!\n");
380 return false;
381 break;
382 }
383
384 dword section_size;
385
386 //section id
387 if(!p_mgetl(&section_id_read,f))
388 {
389 return false;
390 }
391
392 while(!pack_feof(f))
393 {
394 switch(section_id_read)
395 {
396 case ID_RULES:
397 case ID_STRINGS:
398 case ID_MISC:
399 case ID_TILES:
400 case ID_COMBOS:
401 case ID_CSETS:
402 case ID_MAPS:
403 case ID_DMAPS:
404 case ID_DOORS:
405 case ID_ITEMS:
406 case ID_WEAPONS:
407 case ID_COLORS:
408 case ID_ICONS:
409 case ID_INITDATA:
410 case ID_GUYS:
411 case ID_MIDIS:
412 case ID_CHEATS:
413 catchup=false;
414 break;
415
416 default:
417 break;
418 }
419
420
421 while(catchup)
422 {
423 //section id
424 section_id_read=(section_id_read<<8);
425
426 if(!p_getc(&tempbyte,f))
427 {
428 return false;
429 }
430
431 section_id_read+=tempbyte;
432 }
433
434 if(section_id_read==section_id_requested)
435 {
436 return true;
437 }
438 else
439 {
440 //section version info
441 if(!p_igetw(&dummy,f))
442 {
443 return false;
444 }
445
446 if(!p_igetw(&dummy,f))
447 {
448 return false;
449 }
450
451 //section size
452 if(!p_igetl(&section_size,f))
453 {
454 return false;
455 }
456
457 //pack_fseek(f, section_size);
458 while(section_size>65535)
459 {
460 pfread(tempbuf,65535,f);
461 tempbuf[65535]=0;
462 section_size-=65535;
463 }
464
465 if(section_size>0)
466 {
467 pfread(tempbuf,section_size,f);
468 tempbuf[section_size]=0;
469 }
470 }
471
472 //section id
473 if(!p_mgetl(&section_id_read,f))
474 {
475 return false;
476 }
477 }
478
479 return false;
480 }
481
482
483
484
485
486 bool valid_zqt(PACKFILE *f)
487 {
488
489 //word tiles_used;
490 //word combos_used;
491 //open the file
492 //PACKFILE *f = pack_fopen(path, F_READ_PACKED);
493 if(!f)
494 return false;
495
496 //for now, everything else is valid
497 return true;
498
499 /*int16_t version;
500 byte build;
501
502 //read the version and make sure it worked
503 if(!p_igetw(&version,f))
504 {
505 goto error;
506 }
507
508 //read the build and make sure it worked
509 if(!p_getc(&build,f))
510 goto error;
511
512 //read the tile info and make sure it worked
513 if(!p_igetw(&tiles_used,f))
514 {
515 goto error;
516 }
517
518 for (int32_t i=0; i<tiles_used; i++)
519 {
520 if(!pfread(trashbuf,tilesize(tf4Bit),f))
521 {
522 goto error;
523 }
524 }
525
526 //read the combo info and make sure it worked
527 if(!p_igetw(&combos_used,f))
528 {
529 goto error;
530 }
531 for (int32_t i=0; i<combos_used; i++)
532 {
533 if(!pfread(trashbuf,sizeof(newcombo),f))
534 {
535 goto error;
536 }
537 }
538
539 //read the palette info and make sure it worked
540 for (int32_t i=0; i<48; i++)
541 {
542 if(!pfread(trashbuf,newpdTOTAL,f))
543 {
544 goto error;
545 }
546 }
547 if(!pfread(trashbuf,sizeof(palcycle)*256*3,f))
548 {
549 goto error;
550 }
551 for (int32_t i=0; i<MAXLEVELS; i++)
552 {
553 if(!pfread(trashbuf,PALNAMESIZE,f))
554 {
555 goto error;
556 }
557 }
558
559 //read the sprite info and make sure it worked
560 for (int32_t i=0; i<MAXITEMS; i++)
561 {
562 if(!pfread(trashbuf,sizeof(itemdata),f))
563 {
564 goto error;
565 }
566 }
567
568 for (int32_t i=0; i<MAXWPNS; i++)
569 {
570 if(!pfread(trashbuf,sizeof(wpndata),f))
571 {
572 goto error;
573 }
574 }
575
576 //read the triforce pieces info and make sure it worked
577 for (int32_t i=0; i<8; ++i)
578 {
579 if(!p_getc(&trashbuf,f))
580 {
581 goto error;
582 }
583 }
584
585
586
587 //read the game icons info and make sure it worked
588 for (int32_t i=0; i<4; ++i)
589 {
590 if(!p_igetw(&trashbuf,f))
591 {
592 goto error;
593 }
594 }
595
596 //read the misc colors info and map styles info and make sure it worked
597 if(!pfread(trashbuf,sizeof(zcolors),f))
598 {
599 goto error;
600 }
601
602 //read the template screens and make sure it worked
603 byte num_maps;
604 if(!p_getc(&num_maps,f))
605 {
606 goto error;
607 }
608 for (int32_t i=0; i<TEMPLATES; i++)
609 {
610 if(!pfread(trashbuf,sizeof(mapscr),f))
611 {
612 goto error;
613 }
614 }
615 if (num_maps>1) //dungeon templates
616 {
617 for (int32_t i=0; i<TEMPLATES; i++)
618 {
619 if(!pfread(trashbuf,sizeof(mapscr),f))
620 {
621 goto error;
622 }
623 }
624 }
625
626 //yay! it worked! close the file and say everything was ok.
627 pack_fclose(f);
628 return true;
629
630 error:
631 pack_fclose(f);
632 return false;*/
633 }
634
635 bool valid_zqt(const char *filename)
636 {
637 PACKFILE *f=NULL;
638 bool isvalid;
639 int32_t error;
640 f=open_quest_file(&error, filename, false);
641
642 if(!f)
643 {
644 // setPackfilePassword(NULL);
645 return false;
646 }
647
648 isvalid=valid_zqt(f);
649
650 clear_quest_tmpfile();
651 pack_fclose(f);
652
653 // setPackfilePassword(NULL);
654 return isvalid;
655 }
656
657 /*
658 .qst file history
659
660 .qst files have always been compressed using allegro's packfiles.
661
662 At some point, an encoding layer was added. The two layers look like this:
663
664 1) The top layer is from us. See decode_file_007.
665 [0-24] Preamble "Zelda Classic Quest File"
666 [25-28] Initial decoding seed value.
667 [29-X] Allegro-compressed payload (AKA "packed" file), but XOR'd based on seed value
668 [last 4] Checksum
669
670 2) The bottom layer is a "compressed packed file" from Allegro 4. The entire payload
671 is XOR'd with a password (datapwd). Once that is undone, the first four bytes are "slh!",
672 followed by a lzss compressed representation of the payload (from allergo' packfile compression).
673 The oldest quests skip the password part.
674
675 Simply, the job of this function is to peel away the top layer.
676
677 With this second layer of encryption, the data isn't any more secure, and adds a significant delay
678 in opening and saving files. There is no version field, so they decryption key is
679 found via trial-by-error (very slow!)
680
681 There are other file types of interest:
682 - .zqt: quest template files, skips top-layer encryption pass
683 - .qsu: "unencoded" (and uncompressed) files; skips encryption and compression (also makes the longtan password moot)
684 - .qu?: same as above. automated backup files
685 - .qb?: same as above. automated backup files
686 - .qt?: compressed and encrypted (or not encrypted, as of May 2023)
687
688 May 2023: .qst files are now saved without the top layer encoding, and no allegro packfile password. The first bytes of these
689 files are now "slh!.AG ZC Enhanced Quest File".
690 The following command will take an existing qst file and upgrade it: `./zquest -unencrypt-qst <input> <output>`
691 */
692 589 PACKFILE *open_quest_file(int32_t *open_error, const char *filename, bool show_progress)
693 {
694
2/2
✓ Branch 0 taken 588 times.
✓ Branch 1 taken 1 times.
589 if (show_progress)
695 {
696 1 box_start(1, "Loading Quest", get_zc_font(font_lfont), font, true);
697 1 }
698
699 589 auto unencrypted_result = try_open_maybe_legacy_encoded_file(filename, ENC_STR, nullptr, QH_NEWIDSTR, QH_IDSTR);
700
2/2
✓ Branch 0 taken 503 times.
✓ Branch 1 taken 86 times.
589 if (unencrypted_result.decoded_pf)
701 503 return unencrypted_result.decoded_pf;
702
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 86 times.
86 if (unencrypted_result.not_found)
703 {
704 *open_error = qe_notfound;
705 return nullptr;
706 }
707
708 // Everything below here is legacy code - recently saved quest files will have
709 // returned by now.
710 // The only replay qst file that is still using this legacy encoding is `link_to_the_zelda.qst`.
711
712 // Note: although this is primarily for loading .qst files, it can also handle all of the
713 // file types mentioned in the comment above. No need to be told if the file being loaded
714 // is encrypted or compressed, we can do some simple and fast checks to determine how to load it.
715 86 bool top_layer_compressed = unencrypted_result.top_layer_compressed;
716 86 bool compressed = unencrypted_result.compressed;
717 86 bool encrypted = unencrypted_result.encrypted;
718
719 char tmpfilename[L_tmpnam];
720 86 temp_name(tmpfilename);
721 char percent_done[30];
722 86 int32_t current_method=0;
723
724 PACKFILE *f;
725 86 const char *passwd= encrypted ? datapwd : "";
726
727 // oldquest flag is set when an unencrypted qst file is suspected.
728 86 bool oldquest = false;
729 int32_t ret;
730
731
1/2
✓ Branch 0 taken 86 times.
✗ Branch 1 not taken.
86 if(strcmp(filename, "default.qst")!=0)
732 {
733 86 box_out(filename);
734 86 }
735 else
736 {
737 box_out("new quest"); // Or whatever
738 }
739 86 box_out("...");
740 86 box_eol();
741 86 box_eol();
742
743
1/2
✓ Branch 0 taken 86 times.
✗ Branch 1 not taken.
86 if(encrypted)
744 {
745 86 box_out("Decrypting...");
746 86 box_save_x();
747 86 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_MAX-1, top_layer_compressed, passwd);
748
749
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 44 times.
86 if(ret)
750 {
751
1/3
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
44 switch(ret)
752 {
753 case 1:
754 box_out("error.");
755 box_eol();
756 box_end(true);
757 *open_error=qe_notfound;
758 return NULL;
759
760 case 2:
761 box_out("error.");
762 box_eol();
763 box_end(true);
764 *open_error=qe_internal;
765 return NULL;
766 // be sure not to delete tmpfilename now...
767 }
768
769
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 if(ret==5) //old encryption?
770 {
771 44 current_method++;
772 44 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
773 44 box_out(percent_done);
774 44 box_load_x();
775 44 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_211B9, strstr(filename, ".dat#")!=NULL, passwd);
776 44 }
777
778
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 if(ret==5) //old encryption?
779 {
780 44 current_method++;
781 44 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
782 44 box_out(percent_done);
783 44 box_load_x();
784 44 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B185, strstr(filename, ".dat#")!=NULL, passwd);
785 44 }
786
787
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 18 times.
44 if(ret==5) //old encryption?
788 {
789 18 current_method++;
790 18 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
791 18 box_out(percent_done);
792 18 box_load_x();
793 18 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B105, strstr(filename, ".dat#")!=NULL, passwd);
794 18 }
795
796
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 12 times.
44 if(ret==5) //old encryption?
797 {
798 12 current_method++;
799 12 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
800 12 box_out(percent_done);
801 12 box_load_x();
802 12 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B104, strstr(filename, ".dat#")!=NULL, passwd);
803 12 }
804
805
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 if(ret)
806 {
807 oldquest = true;
808 passwd="";
809 }
810 44 }
811
812 86 box_out("okay.");
813 86 box_eol();
814 86 }
815 else
816 {
817 oldquest = true;
818 }
819
820 86 box_out("Opening...");
821
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 86 times.
86 f = pack_fopen_password(oldquest ? filename : tmpfilename, compressed ? F_READ_PACKED : F_READ, passwd);
822
1/2
✓ Branch 0 taken 86 times.
✗ Branch 1 not taken.
86 if(!f)
823 {
824 if((compressed==1)&&(errno==EDOM))
825 {
826 f = pack_fopen_password(oldquest ? filename : tmpfilename, F_READ, passwd);
827 }
828
829 if(!f)
830 {
831 if(!oldquest)
832 {
833 delete_file(tmpfilename);
834 }
835 box_out("error.");
836 box_eol();
837 box_end(true);
838 *open_error=qe_invalid;
839 return NULL;
840 }
841 }
842
843
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 86 times.
86 if(!oldquest)
844 {
845 86 delete_file(tmpfilename);
846 86 }
847
848 86 box_out("okay.");
849 86 box_eol();
850
851 86 return f;
852 589 }
853
854 PACKFILE *open_quest_template(zquestheader *Header, char *deletefilename, bool validate)
855 {
856 char *filename;
857 PACKFILE *f=NULL;
858 int32_t open_error=0;
859
860 strcpy(qstdat_string, "modules/classic/default.qst");
861 if(Header->templatepath[0]==0)
862 {
863 filename=(char *)malloc(2048);
864 strcpy(filename, qstdat_string);
865 }
866 else
867 {
868 // TODO: should be safe to remove this, no one seems to use custom quest templates.
869 filename=Header->templatepath;
870 }
871
872 f=open_quest_file(&open_error, filename, false);
873
874 if(Header->templatepath[0]==0)
875 {
876 free(filename);
877 }
878
879 if(!f)
880 {
881 return NULL;
882 }
883
884 if(validate)
885 {
886 if(!valid_zqt(f))
887 {
888 jwin_alert("Error","Invalid Quest Template",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
889 pack_fclose(f);
890 clear_quest_tmpfile();
891 return NULL;
892 }
893 }
894
895 return f;
896 }
897
898 bool init_section(zquestheader *Header, int32_t section_id, miscQdata *Misc, zctune *tunes, bool validate)
899 {
900 // We absolutely do not support loading from a template file to initialize data outside the editor.
901 // TODO: move this code into zq/
902 if (get_app_id() != App::zquest) return false;
903
904 combosread=false;
905 mapsread=false;
906 fixffcs=false;
907
908 switch(section_id)
909 {
910 case ID_RULES:
911 case ID_STRINGS:
912 case ID_MISC:
913 case ID_TILES:
914 case ID_COMBOS:
915 case ID_CSETS:
916 case ID_MAPS:
917 case ID_DMAPS:
918 case ID_DOORS:
919 case ID_ITEMS:
920 case ID_WEAPONS:
921 case ID_COLORS:
922 case ID_ICONS:
923 case ID_INITDATA:
924 case ID_GUYS:
925 case ID_MIDIS:
926 case ID_CHEATS:
927 case ID_ITEMDROPSETS:
928 case ID_FAVORITES:
929 break;
930
931 default:
932 return false;
933 break;
934 }
935
936 int32_t ret;
937 word version, build;
938 PACKFILE *f=NULL;
939
940 char deletefilename[1024];
941 deletefilename[0]=0;
942
943 //why is this here?
944 /*
945 if(colordata==NULL)
946 return false;
947 */
948
949 //setPackfilePassword(datapwd);
950 f=open_quest_template(Header, deletefilename, validate);
951
952 if(!f) //no file, nothing to delete
953 {
954 // setPackfilePassword(NULL);
955 return false;
956 }
957
958 ret=get_version_and_build(f, &version, &build);
959
960 if(ret||(version==0))
961 {
962 pack_fclose(f);
963 clear_quest_tmpfile();
964
965 if(deletefilename[0])
966 {
967 delete_file(deletefilename);
968 }
969
970 // setPackfilePassword(NULL);
971 return false;
972 }
973
974 if(!find_section(f, section_id))
975 {
976 al_trace("Can't find section!\n");
977 pack_fclose(f);
978 clear_quest_tmpfile();
979
980 if(deletefilename[0])
981 {
982 delete_file(deletefilename);
983 }
984
985 //setPackfilePassword(NULL);
986 return false;
987 }
988
989 switch(section_id)
990 {
991 case ID_RULES:
992 //rules
993 ret=readrules(f, Header);
994 break;
995
996 case ID_STRINGS:
997 //strings
998 ret=readstrings(f, Header);
999 break;
1000
1001 case ID_MISC:
1002 //misc data
1003 ret=readmisc(f, Header, Misc);
1004 break;
1005
1006 case ID_TILES:
1007 //tiles
1008 ret=readtiles(f, newtilebuf, Header, version, build, 0, NEWMAXTILES, true);
1009 break;
1010
1011 case ID_COMBOS:
1012 //combos
1013 clear_combos();
1014 ret=readcombos(f, Header, version, build, 0, MAXCOMBOS);
1015 combosread=true;
1016 break;
1017
1018 case ID_COMBOALIASES:
1019 //combos
1020 ret=readcomboaliases(f, Header, version, build);
1021 break;
1022
1023 case ID_CSETS:
1024 //color data
1025 ret=readcolordata(f, Misc, version, build, 0, newerpdTOTAL);
1026 break;
1027
1028 case ID_MAPS:
1029 //maps
1030 ret=readmaps(f, Header);
1031 mapsread=true;
1032 break;
1033
1034 case ID_DMAPS:
1035 //dmaps
1036 ret=readdmaps(f, Header, version, build, 0, MAXDMAPS);
1037 break;
1038
1039 case ID_DOORS:
1040 //door combo sets
1041 ret=readdoorcombosets(f, Header);
1042 break;
1043
1044 case ID_ITEMS:
1045 //items
1046 ret=readitems(f, version, build);
1047 break;
1048
1049 case ID_WEAPONS:
1050 //weapons
1051 ret=readweapons(f, Header);
1052 break;
1053
1054 case ID_COLORS:
1055 //misc. colors
1056 ret=readmisccolors(f, Header, Misc);
1057 break;
1058
1059 case ID_ICONS:
1060 //game icons
1061 ret=readgameicons(f, Header, Misc);
1062 break;
1063
1064 case ID_INITDATA:
1065 //initialization data
1066 ret=readinitdata(f, Header);
1067 break;
1068
1069 case ID_GUYS:
1070 //guys
1071 ret=readguys(f, Header);
1072 break;
1073
1074 case ID_MIDIS:
1075 //midis
1076 ret=readtunes(f, Header, tunes);
1077 break;
1078
1079 case ID_CHEATS:
1080 //cheat codes
1081 ret=readcheatcodes(f, Header);
1082 break;
1083
1084 case ID_ITEMDROPSETS:
1085 //item drop sets
1086 // Why is this one commented out?
1087 //ret=readitemdropsets(f, (int32_t)version, (word)build);
1088 break;
1089
1090 case ID_FAVORITES:
1091 // favorite combos and aliases
1092 ret=readfavorites(f, version, build);
1093 break;
1094
1095 default:
1096 ret=-1;
1097 break;
1098 }
1099
1100 pack_fclose(f);
1101 clear_quest_tmpfile();
1102
1103 if(deletefilename[0])
1104 {
1105 delete_file(deletefilename);
1106 }
1107
1108 //setPackfilePassword(NULL);
1109 if(!ret)
1110 {
1111 return true;
1112 }
1113
1114 return false;
1115 }
1116
1117 bool init_tiles(bool validate, zquestheader *Header)
1118 {
1119 return init_section(Header, ID_TILES, NULL, NULL, validate);
1120 }
1121
1122 bool init_combos(bool validate, zquestheader *Header)
1123 {
1124 return init_section(Header, ID_COMBOS, NULL, NULL, validate);
1125 }
1126
1127 bool init_colordata(bool validate, zquestheader *Header, miscQdata *Misc)
1128 {
1129 return init_section(Header, ID_CSETS, Misc, NULL, validate);
1130 }
1131
1132 589 void init_spritelists()
1133 {
1134
2/2
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 394 times.
589 if(FFCore.quest_format[vZelda] < 0x255)
1135 {
1136 195 guys.setMax(255);
1137 195 items.setMax(255);
1138 195 Ewpns.setMax(255);
1139 195 Lwpns.setMax(255);
1140 195 chainlinks.setMax(255);
1141 195 decorations.setMax(255);
1142 195 particles.setMax(255);
1143 195 }
1144 else
1145 {
1146 394 guys.setMax(255);
1147 394 items.setMax(255);
1148 394 Ewpns.setMax(255);
1149 394 Lwpns.setMax(255);
1150 394 chainlinks.setMax(255);
1151 394 decorations.setMax(255);
1152 394 particles.setMax(255*((255*4)+1)); //255 per sprite that can use particles; guys, items, ewpns, lwpns, +HERO
1153 }
1154 589 }
1155
1156 262 bool reset_items(bool validate, zquestheader *Header)
1157 {
1158 262 bool ret = true;
1159
1/2
✓ Branch 0 taken 262 times.
✗ Branch 1 not taken.
262 if (get_app_id() == App::zquest)
1160 ret = init_section(Header, ID_ITEMS, NULL, NULL, validate);
1161
1162
2/2
✓ Branch 0 taken 262 times.
✓ Branch 1 taken 67072 times.
67334 for(int32_t i=0; i<MAXITEMS; i++) reset_itemname(i);
1163
1164 262 return ret;
1165 }
1166
1167 bool reset_guys()
1168 {
1169 // The .dat file's guys definitions are always synchronised with defdata.cpp's - even the tile settings.
1170 init_guys(V_GUYS);
1171 return true;
1172 }
1173
1174 bool reset_wpns(bool validate, zquestheader *Header)
1175 {
1176 bool ret = true;
1177 if (get_app_id() == App::zquest)
1178 ret = init_section(Header, ID_WEAPONS, NULL, NULL, validate);
1179
1180 for(int32_t i=0; i<MAXWPNS; i++)
1181 reset_weaponname(i);
1182
1183 return ret;
1184 }
1185
1186 bool reset_mapstyles(bool validate, miscQdata *Misc)
1187 {
1188 Misc->colors.blueframe_tile = 20044;
1189 Misc->colors.blueframe_cset = 0;
1190 Misc->colors.triforce_tile = 23461;
1191 Misc->colors.triforce_cset = 1;
1192 Misc->colors.triframe_tile = 18752;
1193 Misc->colors.triframe_cset = 1;
1194 Misc->colors.overworld_map_tile = 16990;
1195 Misc->colors.overworld_map_cset = 2;
1196 Misc->colors.HCpieces_tile = 21160;
1197 Misc->colors.HCpieces_cset = 8;
1198 Misc->colors.dungeon_map_tile = 19651;
1199 Misc->colors.dungeon_map_cset = 8;
1200 return true;
1201 }
1202
1203 308 int32_t get_qst_buffers()
1204 {
1205 308 TheMaps.resize(MAPSCRS);
1206 308 map_autolayers.resize(6);
1207
1208
2/2
✓ Branch 0 taken 41888 times.
✓ Branch 1 taken 308 times.
42196 for(int32_t i(0); i<MAPSCRS; i++)
1209 41888 TheMaps[i].zero_memory();
1210
1211 //memset(TheMaps, 0, sizeof(mapscr)*MAPSCRS); //shouldn't need this anymore
1212 308 Z_message("OK\n");
1213
1214 // The vast majority of finished quests (and I presume this will be consistent for all time) use < 1000 strings in total.
1215 // (Shoelace's "Hero of Dreams" uses 1415.)
1216 // So let's be a bit generous and allow 4096 initially.
1217 // In the rare event that a quest overshoots this mark, we'll reallocate to the full 65535 later.
1218 // I tested it and it worked without flaw on 6/6/11. - L.
1219 // 2022: bumped from 4096 to 8192 to avoid a bug where the Strings menu shows (None) strings when the list passes
1220 // this threshold. Possibly some bug related to `msglistcache` to being reset?
1221 // See https://discord.com/channels/876899628556091432/992984989073416242
1222 308 msg_strings_size = 8192;
1223
1224
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 308 times.
308 MsgStrings = new MsgStr[msg_strings_size];
1225
1226 //memset(MsgStrings, 0, sizeof(MsgStr)*msg_strings_size);
1227
2/2
✓ Branch 0 taken 2523136 times.
✓ Branch 1 taken 308 times.
2523444 for(auto q = 0; q < msg_strings_size; ++q)
1228 {
1229 2523136 MsgStrings[q].clear();
1230 2523136 }
1231
1232
1233
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if((DoorComboSets=(DoorComboSet*)malloc(sizeof(DoorComboSet)*MAXDOORCOMBOSETS))==NULL)
1234 return 0;
1235
1236
1237
1238
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if((DMaps=new dmap[MAXDMAPS])==NULL)
1239 return 0;
1240
1241
1242
1243 308 combobuf.clear();
1244 308 combobuf.resize(MAXCOMBOS);
1245
1246
1247
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if((colordata=(byte*)malloc(psTOTAL255))==NULL)
1248 return 0;
1249
1250 308 free_newtilebuf();
1251
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if((newtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1252 return 0;
1253
1254 308 memset(newtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1255 //Z_message("Performed memset on tiles\n");
1256 308 clear_tiles(newtilebuf);
1257 //Z_message("Performed clear_tiles()\n");
1258
1259
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 9 times.
308 if(is_editor())
1260 {
1261
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if((grabtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1262 return 0;
1263
1264 9 memset(grabtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1265 9 clear_tiles(grabtilebuf);
1266 9 }
1267
1268
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if((trashbuf=(byte*)malloc(100000))==NULL)
1269 return 0;
1270
1271 // Big, ugly band-aid here. Perhaps the most common cause of random crashes
1272 // has been inadvertently accessing itemsbuf[-1]. All such crashes should be
1273 // fixed by ensuring there's actually itemdata there.
1274 // If you change this, be sure to update del_qst_buffers, too.
1275
1276
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if((itemsbuf=(itemdata*)malloc(sizeof(itemdata)*(MAXITEMS+1)))==NULL)
1277 return 0;
1278
1279 308 memset(itemsbuf,0,sizeof(itemdata)*(MAXITEMS+1));
1280 308 itemsbuf++;
1281
1282
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if((wpnsbuf=(wpndata*)malloc(sizeof(wpndata)*MAXWPNS))==NULL)
1283 return 0;
1284
1285 308 memset(wpnsbuf,0,sizeof(wpndata)*MAXWPNS);
1286
1287
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if((guysbuf=(guydata*)malloc(sizeof(guydata)*MAXGUYS))==NULL)
1288 return 0;
1289
1290 308 memset(guysbuf,0,sizeof(guydata)*MAXGUYS);
1291
1292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 308 times.
308 if((combo_class_buf=(comboclass*)malloc(sizeof(comboclass)*cMAX))==NULL)
1293 return 0;
1294
1295 308 return 1;
1296 308 }
1297
1298
1299 308 void free_newtilebuf()
1300 {
1301
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 307 times.
308 if(newtilebuf)
1302 {
1303
2/2
✓ Branch 0 taken 214500 times.
✓ Branch 1 taken 1 times.
214501 for(int32_t i=0; i<NEWMAXTILES; i++)
1304
1/2
✓ Branch 0 taken 214500 times.
✗ Branch 1 not taken.
214500 if(newtilebuf[i].data)
1305 free(newtilebuf[i].data);
1306
1307 1 free(newtilebuf);
1308 1 newtilebuf = 0;
1309 1 }
1310 308 }
1311
1312 void free_grabtilebuf()
1313 {
1314 if(is_editor())
1315 {
1316 if(grabtilebuf)
1317 {
1318 for(int32_t i=0; i<NEWMAXTILES; i++)
1319 if(grabtilebuf[i].data) free(grabtilebuf[i].data);
1320
1321 free(grabtilebuf);
1322 grabtilebuf = 0;
1323 }
1324 }
1325 }
1326
1327 void del_qst_buffers()
1328 {
1329 if(MsgStrings) delete[] MsgStrings;
1330
1331 if(DoorComboSets) free(DoorComboSets);
1332
1333 if (DMaps) delete[] DMaps;
1334
1335 combobuf.clear();
1336
1337 if(colordata) free(colordata);
1338
1339 free_newtilebuf();
1340 free_grabtilebuf();
1341
1342 if(trashbuf) free(trashbuf);
1343
1344 // See get_qst_buffers
1345 if(itemsbuf)
1346 {
1347 itemsbuf--;
1348 free(itemsbuf);
1349 }
1350
1351 if(wpnsbuf) free(wpnsbuf);
1352
1353 if(guysbuf) free(guysbuf);
1354
1355 if(combo_class_buf) free(combo_class_buf);
1356 }
1357
1358 18 bool init_palnames()
1359 {
1360 // if(palnames==NULL)
1361 // return false;
1362
1363
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 18 times.
9234 for(int32_t x=0; x<MAXLEVELS; x++)
1364 {
1365
4/4
✓ Branch 0 taken 9162 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 18 times.
9216 switch(x)
1366 {
1367 case 0:
1368 18 sprintf(palnames[x],"Overworld");
1369 18 break;
1370
1371 case 10:
1372 18 sprintf(palnames[x],"Caves");
1373 18 break;
1374
1375 case 11:
1376 18 sprintf(palnames[x],"Passageways");
1377 18 break;
1378
1379 default:
1380 9162 sprintf(palnames[x],"%c",0);
1381 9162 break;
1382 }
1383 9216 }
1384
1385 18 return true;
1386 }
1387
1388 61000 static void *read_block(PACKFILE *f, int32_t size, int32_t alloc_size)
1389 {
1390 void *p;
1391
1392
1/2
✓ Branch 0 taken 61000 times.
✗ Branch 1 not taken.
61000 p = _AL_MALLOC(MAX(size, alloc_size));
1393
1394
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61000 times.
61000 if(!p)
1395 {
1396 return NULL;
1397 }
1398
1399
1/2
✓ Branch 0 taken 61000 times.
✗ Branch 1 not taken.
61000 if(!pfread(p,size,f))
1400 {
1401 _AL_FREE(p);
1402 return NULL;
1403 }
1404
1405
1/2
✓ Branch 0 taken 61000 times.
✗ Branch 1 not taken.
61000 if(pack_ferror(f))
1406 {
1407 _AL_FREE(p);
1408 return NULL;
1409 }
1410
1411 61000 return p;
1412 61000 }
1413
1414 // Only use for reading parts of older quests (Header->zelda_version <= 0x192)
1415 static const byte* legacy_skip_flags;
1416
1417 /* read_midi:
1418 * Reads MIDI data from a datafile (this is not the same thing as the
1419 * standard midi file format).
1420 */
1421
1422 6327 static MIDI *read_midi(PACKFILE *f)
1423 {
1424 MIDI *m;
1425 int32_t c;
1426 6327 int16_t divisions=0;
1427 6327 int32_t len=0;
1428
1429 6327 m = (MIDI*)_AL_MALLOC(sizeof(MIDI));
1430
1431
1/2
✓ Branch 0 taken 6327 times.
✗ Branch 1 not taken.
6327 if(!m)
1432 {
1433 return NULL;
1434 }
1435
1436
2/2
✓ Branch 0 taken 202464 times.
✓ Branch 1 taken 6327 times.
208791 for(c=0; c<MIDI_TRACKS; c++)
1437 {
1438 202464 m->track[c].len = 0;
1439 202464 m->track[c].data = NULL;
1440 202464 }
1441
1442 6327 p_mgetw(&divisions,f);
1443 6327 m->divisions=divisions;
1444
1445
2/2
✓ Branch 0 taken 202464 times.
✓ Branch 1 taken 6327 times.
208791 for(c=0; c<MIDI_TRACKS; c++)
1446 {
1447 202464 p_mgetl(&len,f);
1448 202464 m->track[c].len=len;
1449
1450
2/2
✓ Branch 0 taken 141464 times.
✓ Branch 1 taken 61000 times.
202464 if(m->track[c].len > 0)
1451 {
1452 61000 m->track[c].data = (byte*)read_block(f, m->track[c].len, 0);
1453
1454
1/2
✓ Branch 0 taken 61000 times.
✗ Branch 1 not taken.
61000 if(!m->track[c].data)
1455 {
1456 destroy_midi(m);
1457 return NULL;
1458 }
1459 61000 }
1460 202464 }
1461
1462 LOCK_DATA(m, sizeof(MIDI));
1463
1464
2/2
✓ Branch 0 taken 202464 times.
✓ Branch 1 taken 6327 times.
208791 for(c=0; c<MIDI_TRACKS; c++)
1465 {
1466
2/2
✓ Branch 0 taken 61000 times.
✓ Branch 1 taken 141464 times.
202464 if(m->track[c].data)
1467 {
1468 LOCK_DATA(m->track[c].data, m->track[c].len);
1469 61000 }
1470 202464 }
1471
1472 6327 return m;
1473 6327 }
1474
1475 void clear_combo(int32_t i)
1476 {
1477 combobuf[i].clear();
1478 }
1479
1480 void clear_combos()
1481 {
1482 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
1483 clear_combo(tmpcounter);
1484 }
1485
1486 void pack_combos()
1487 {
1488 int32_t di = 0;
1489
1490 for(int32_t si=0; si<1024; si+=2)
1491 combobuf[di++] = combobuf[si];
1492
1493 for(; di<1024; di++)
1494 clear_combo(di);
1495 }
1496
1497 588 void reset_tunes(zctune *tune)
1498 {
1499
2/2
✓ Branch 0 taken 148176 times.
✓ Branch 1 taken 588 times.
148764 for(int32_t i=0; i<MAXCUSTOMTUNES; i++)
1500 {
1501 148176 tune[i].reset();
1502 148176 }
1503 588 }
1504
1505
1506 /*void reset_midi(zcmidi_ *m)
1507 {
1508 m->title[0]=0;
1509 m->loop=1;
1510 m->volume=144;
1511 m->start=0;
1512 m->loop_start=-1;
1513 m->loop_end=-1;
1514 if(m->midi)
1515 {
1516 destroy_midi(m->midi);
1517 }
1518 m->midi=NULL;
1519 }
1520
1521
1522 void reset_midis(zcmidi_ *m)
1523 {
1524 for(int32_t i=0; i<MAXCUSTOMMIDIS; i++)
1525 {
1526 reset_midi(m+i);
1527 }
1528 }
1529 */
1530
1531 void reset_scr(int32_t scr)
1532 {
1533 /*
1534 byte *di=((byte*)TheMaps)+(scr*sizeof(mapscr));
1535 for(unsigned i=0; i<sizeof(mapscr); i++)
1536 *(di++) = 0;
1537 TheMaps[scr].valid=mVERSION;
1538 */
1539
1540 TheMaps[scr].zero_memory();
1541 //byte *di=((byte*)TheMaps)+(scr*sizeof(mapscr));
1542
1543 for(int32_t i=0; i<6; i++)
1544 {
1545 //these will be uncommented later
1546 //TheMaps[scr].layerxsize[i]=16;
1547 //TheMaps[scr].layerysize[i]=11;
1548 TheMaps[scr].layeropacity[i]=255;
1549 }
1550
1551 TheMaps[scr].valid=mVERSION;
1552
1553 }
1554
1555 /* For reference:
1556
1557 enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
1558 qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
1559 */
1560
1561 28922 int32_t operator ==(DoorComboSet a, DoorComboSet b)
1562 {
1563
2/2
✓ Branch 0 taken 63938 times.
✓ Branch 1 taken 4377 times.
68315 for(int32_t i=0; i<9; i++)
1564 {
1565
2/2
✓ Branch 0 taken 262433 times.
✓ Branch 1 taken 39699 times.
302132 for(int32_t j=0; j<6; j++)
1566 {
1567
2/2
✓ Branch 0 taken 79398 times.
✓ Branch 1 taken 183035 times.
262433 if(j<4)
1568 {
1569
2/2
✓ Branch 0 taken 158796 times.
✓ Branch 1 taken 24239 times.
183035 if(a.doorcombo_u[i][j]!=b.doorcombo_u[i][j])
1570 {
1571 24239 return false;
1572 }
1573
1574
1/2
✓ Branch 0 taken 158796 times.
✗ Branch 1 not taken.
158796 if(a.doorcset_u[i][j]!=b.doorcset_u[i][j])
1575 {
1576 return false;
1577 }
1578
1579
1/2
✓ Branch 0 taken 158796 times.
✗ Branch 1 not taken.
158796 if(a.doorcombo_d[i][j]!=b.doorcombo_d[i][j])
1580 {
1581 return false;
1582 }
1583
1584
1/2
✓ Branch 0 taken 158796 times.
✗ Branch 1 not taken.
158796 if(a.doorcset_d[i][j]!=b.doorcset_d[i][j])
1585 {
1586 return false;
1587 }
1588 158796 }
1589
1590
1/2
✓ Branch 0 taken 238194 times.
✗ Branch 1 not taken.
238194 if(a.doorcombo_l[i][j]!=b.doorcombo_l[i][j])
1591 {
1592 return false;
1593 }
1594
1595
1/2
✓ Branch 0 taken 238194 times.
✗ Branch 1 not taken.
238194 if(a.doorcset_l[i][j]!=b.doorcset_l[i][j])
1596 {
1597 return false;
1598 }
1599
1600
1/2
✓ Branch 0 taken 238194 times.
✗ Branch 1 not taken.
238194 if(a.doorcombo_r[i][j]!=b.doorcombo_r[i][j])
1601 {
1602 return false;
1603 }
1604
1605
1/2
✓ Branch 0 taken 238194 times.
✗ Branch 1 not taken.
238194 if(a.doorcset_r[i][j]!=b.doorcset_r[i][j])
1606 {
1607 return false;
1608 }
1609 238194 }
1610
1611
2/2
✓ Branch 0 taken 30639 times.
✓ Branch 1 taken 9060 times.
39699 if(i<2)
1612 {
1613
1/2
✓ Branch 0 taken 9060 times.
✗ Branch 1 not taken.
9060 if(a.flags[i]!=b.flags[i])
1614 {
1615 return false;
1616 }
1617
1618
2/2
✓ Branch 0 taken 9036 times.
✓ Branch 1 taken 24 times.
9060 if(a.bombdoorcombo_u[i]!=b.bombdoorcombo_u[i])
1619 {
1620 24 return false;
1621 }
1622
1623
1/2
✓ Branch 0 taken 9036 times.
✗ Branch 1 not taken.
9036 if(a.bombdoorcset_u[i]!=b.bombdoorcset_u[i])
1624 {
1625 return false;
1626 }
1627
1628
1/2
✓ Branch 0 taken 9036 times.
✗ Branch 1 not taken.
9036 if(a.bombdoorcombo_d[i]!=b.bombdoorcombo_d[i])
1629 {
1630 return false;
1631 }
1632
1633
1/2
✓ Branch 0 taken 9036 times.
✗ Branch 1 not taken.
9036 if(a.bombdoorcset_d[i]!=b.bombdoorcset_d[i])
1634 {
1635 return false;
1636 }
1637 9036 }
1638
1639
2/2
✓ Branch 0 taken 26262 times.
✓ Branch 1 taken 13413 times.
39675 if(i<3)
1640 {
1641
1/2
✓ Branch 0 taken 13413 times.
✗ Branch 1 not taken.
13413 if(a.bombdoorcombo_l[i]!=b.bombdoorcombo_l[i])
1642 {
1643 return false;
1644 }
1645
1646
1/2
✓ Branch 0 taken 13413 times.
✗ Branch 1 not taken.
13413 if(a.bombdoorcset_l[i]!=b.bombdoorcset_l[i])
1647 {
1648 return false;
1649 }
1650
1651
1/2
✓ Branch 0 taken 13413 times.
✗ Branch 1 not taken.
13413 if(a.bombdoorcombo_r[i]!=b.bombdoorcombo_r[i])
1652 {
1653 return false;
1654 }
1655
1656
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13413 times.
13413 if(a.bombdoorcset_r[i]!=b.bombdoorcset_r[i])
1657 {
1658 return false;
1659 }
1660 13413 }
1661
1662
2/2
✓ Branch 0 taken 39393 times.
✓ Branch 1 taken 282 times.
39675 if(a.walkthroughcombo[i]!=b.walkthroughcombo[i])
1663 {
1664 282 return false;
1665 }
1666
1667
1/2
✓ Branch 0 taken 39393 times.
✗ Branch 1 not taken.
39393 if(a.walkthroughcset[i]!=b.walkthroughcset[i])
1668 {
1669 return false;
1670 }
1671 39393 }
1672
1673 4377 return true;
1674 28922 }
1675
1676 int32_t doortranslations_u[9][4]=
1677 {
1678 {37,38,53,54},
1679 {37,38,39,40},
1680 {37,38,55,56},
1681 {37,38,39,40},
1682 {37,38,53,54},
1683 {37,38,53,54},
1684 {37,38,53,54},
1685 {7,8,23,24},
1686 {7,8,41,42}
1687 };
1688
1689 int32_t doortranslations_d[9][4]=
1690 {
1691 {117,118,133,134},
1692 {135,136,133,134},
1693 {119,120,133,134},
1694 {135,136,133,134},
1695 {117,118,133,134},
1696 {117,118,133,134},
1697 {117,118,133,134},
1698 {151,152,167,168},
1699 {137,138,167,168},
1700 };
1701
1702 //enum {dt_pass=0, dt_lock, dt_shut, dt_boss, dt_olck, dt_osht, dt_obos, dt_wall, dt_bomb, dt_walk, dt_max};
1703 int32_t doortranslations_l[9][6]=
1704 {
1705 {66,67,82,83,98,99},
1706 {66,68,82,84,98,100},
1707 {66,69,82,85,98,101},
1708 {66,68,82,84,98,100},
1709 {66,67,82,83,98,99},
1710 {66,67,82,83,98,99},
1711 {66,67,82,83,98,99},
1712 {64,65,80,81,96,97},
1713 {64,65,80,114,96,97},
1714 };
1715
1716 int32_t doortranslations_r[9][6]=
1717 {
1718
1719 {76,77,92,93,108,109},
1720 {75,77,91,93,107,109},
1721 {74,77,90,93,106,109},
1722 {75,77,91,93,107,109},
1723 {76,77,92,93,108,109},
1724 {76,77,92,93,108,109},
1725 {76,77,92,93,108,109},
1726 {78,79,94,95,110,111},
1727 {78,79,125,95,110,111},
1728 };
1729
1730 858450 int32_t tdcmbdat(int32_t map, int32_t scr, int32_t pos)
1731 {
1732 858450 return (TheMaps[map*MAPSCRS+TEMPLATE].data[pos]&0xFF)+((TheMaps[map*MAPSCRS+scr].old_cpage)<<8);
1733 }
1734
1735 840750 int32_t tdcmbcset(int32_t map, int32_t scr, int32_t pos)
1736 {
1737 //these are here to bypass compiler warnings about unused arguments
1738 840750 map=map;
1739 840750 scr=scr;
1740 840750 pos=pos;
1741
1742 //what does this function do?
1743 // return TheMaps[map*MAPSCRS+TEMPLATE].cset[pos];
1744 840750 return 2;
1745 }
1746
1747 22848 int32_t MakeDoors(int32_t map, int32_t scr)
1748 {
1749
2/2
✓ Branch 0 taken 18423 times.
✓ Branch 1 taken 4425 times.
22848 if(!(TheMaps[map*MAPSCRS+scr].valid&mVALID))
1750 {
1751 18423 return 0;
1752 }
1753
1754 DoorComboSet tempdcs;
1755 4425 memset(&tempdcs, 0, sizeof(DoorComboSet));
1756
1757 //up
1758
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1759 {
1760
2/2
✓ Branch 0 taken 159300 times.
✓ Branch 1 taken 39825 times.
199125 for(int32_t j=0; j<4; j++)
1761 {
1762 159300 tempdcs.doorcombo_u[i][j]=tdcmbdat(map,scr,doortranslations_u[i][j]);
1763 159300 tempdcs.doorcset_u[i][j]=tdcmbcset(map,scr,doortranslations_u[i][j]);
1764 159300 }
1765 39825 }
1766
1767 4425 tempdcs.bombdoorcombo_u[0]=tdcmbdat(map,scr,57);
1768 4425 tempdcs.bombdoorcset_u[0]=tdcmbcset(map,scr,57);
1769 4425 tempdcs.bombdoorcombo_u[1]=tdcmbdat(map,scr,58);
1770 4425 tempdcs.bombdoorcset_u[1]=tdcmbcset(map,scr,58);
1771 4425 tempdcs.walkthroughcombo[0]=tdcmbdat(map,scr,34);
1772 4425 tempdcs.walkthroughcset[0]=tdcmbdat(map,scr,34);
1773
1774 //down
1775
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1776 {
1777
2/2
✓ Branch 0 taken 159300 times.
✓ Branch 1 taken 39825 times.
199125 for(int32_t j=0; j<4; j++)
1778 {
1779 159300 tempdcs.doorcombo_d[i][j]=tdcmbdat(map,scr,doortranslations_d[i][j]);
1780 159300 tempdcs.doorcset_d[i][j]=tdcmbcset(map,scr,doortranslations_d[i][j]);
1781 159300 }
1782 39825 }
1783
1784 4425 tempdcs.bombdoorcombo_d[0]=tdcmbdat(map,scr,121);
1785
1786 4425 tempdcs.bombdoorcset_d[0]=tdcmbcset(map,scr,121);
1787 4425 tempdcs.bombdoorcombo_d[1]=tdcmbdat(map,scr,122);
1788 4425 tempdcs.bombdoorcset_d[1]=tdcmbcset(map,scr,122);
1789 4425 tempdcs.walkthroughcombo[1]=tdcmbdat(map,scr,34);
1790 4425 tempdcs.walkthroughcset[1]=tdcmbdat(map,scr,34);
1791
1792 //left
1793 // TheMaps[i*MAPSCRS+j].warpdmap=TheOldMap.warpdmap;
1794
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1795 {
1796
2/2
✓ Branch 0 taken 238950 times.
✓ Branch 1 taken 39825 times.
278775 for(int32_t j=0; j<6; j++)
1797 {
1798 238950 tempdcs.doorcombo_l[i][j]=tdcmbdat(map,scr,doortranslations_l[i][j]);
1799 238950 tempdcs.doorcset_l[i][j]=tdcmbcset(map,scr,doortranslations_l[i][j]);
1800 238950 }
1801 39825 }
1802
1803
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4425 times.
4425 for(int32_t j=0; j>6; j++)
1804 {
1805 if((j!=2)&&(j!=3))
1806 {
1807 tempdcs.doorcombo_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_l[dt_bomb][j]];
1808 tempdcs.doorcset_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_l[dt_bomb][j]];
1809 }
1810 }
1811
1812 4425 tempdcs.bombdoorcombo_l[0]=0;
1813 4425 tempdcs.bombdoorcset_l[0]=tdcmbcset(map,scr,115);
1814 4425 tempdcs.bombdoorcombo_l[1]=tdcmbdat(map,scr,115);
1815 4425 tempdcs.bombdoorcset_l[1]=tdcmbcset(map,scr,115);
1816 4425 tempdcs.bombdoorcombo_l[2]=0;
1817 4425 tempdcs.bombdoorcset_l[2]=tdcmbcset(map,scr,115);
1818 4425 tempdcs.walkthroughcombo[2]=tdcmbdat(map,scr,34);
1819 4425 tempdcs.walkthroughcset[2]=tdcmbdat(map,scr,34);
1820
1821 //right
1822
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1823 {
1824
2/2
✓ Branch 0 taken 238950 times.
✓ Branch 1 taken 39825 times.
278775 for(int32_t j=0; j<6; j++)
1825 {
1826 238950 tempdcs.doorcombo_r[i][j]=tdcmbdat(map,scr,doortranslations_r[i][j]);
1827 238950 tempdcs.doorcset_r[i][j]=tdcmbcset(map,scr,doortranslations_r[i][j]);
1828 238950 }
1829 39825 }
1830
1831
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4425 times.
4425 for(int32_t j=0; j>6; j++)
1832 {
1833 if((j!=2)&&(j!=3))
1834 {
1835 tempdcs.doorcombo_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_r[dt_bomb][j]];
1836 tempdcs.doorcset_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_r[dt_bomb][j]];
1837 }
1838 }
1839
1840 4425 tempdcs.bombdoorcombo_r[0]=0;
1841 4425 tempdcs.bombdoorcset_r[0]=tdcmbcset(map,scr,124);
1842 4425 tempdcs.bombdoorcombo_r[1]=tdcmbdat(map,scr,124);
1843 4425 tempdcs.bombdoorcset_r[1]=tdcmbcset(map,scr,124);
1844 4425 tempdcs.bombdoorcombo_r[2]=0;
1845 4425 tempdcs.bombdoorcset_r[2]=tdcmbcset(map,scr,124);
1846 4425 tempdcs.walkthroughcombo[3]=tdcmbdat(map,scr,34);
1847 4425 tempdcs.walkthroughcset[3]=tdcmbdat(map,scr,34);
1848
1849 int32_t k;
1850
1851
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 28922 times.
28970 for(k=0; k<door_combo_set_count; k++)
1852 {
1853
2/2
✓ Branch 0 taken 4377 times.
✓ Branch 1 taken 24545 times.
28922 if(DoorComboSets[k]==tempdcs)
1854 {
1855 4377 break;
1856 }
1857 24545 }
1858
1859
2/2
✓ Branch 0 taken 4377 times.
✓ Branch 1 taken 48 times.
4425 if(k==door_combo_set_count)
1860 {
1861 48 DoorComboSets[k]=tempdcs;
1862 48 sprintf(DoorComboSets[k].name, "Door Combo Set %d", k);
1863 48 ++door_combo_set_count;
1864 48 }
1865
1866 4425 return k;
1867 /*
1868 doorcombo_u[9][4];
1869 doorcset_u[9][4];
1870 doorcombo_d[9][4];
1871 doorcset_d[9][4];
1872 doorcombo_l[9][6];
1873 doorcset_l[9][6];
1874 doorcombo_r[9][6];
1875 doorcset_r[9][6];
1876 bombdoorcombo_u[2];
1877 bombdoorcset_u[2];
1878 bombdoorcombo_d[2];
1879 bombdoorcset_d[2];
1880 bombdoorcombo_l[3];
1881 bombdoorcset_l[3];
1882 bombdoorcombo_r[3];
1883 bombdoorcset_r[3];
1884 walkthroughcombo[4];
1885 walkthroughcset[4];
1886 */
1887 22848 }
1888
1889 2924544 INLINE int32_t tcmbdat2(int32_t map, int32_t scr, int32_t pos)
1890 {
1891 2924544 return (TheMaps[map*MAPSCRS+TEMPLATE2].data[pos]&0xFF)+((TheMaps[map*MAPSCRS+scr].old_cpage)<<8);
1892 }
1893
1894 2924544 INLINE int32_t tcmbcset2(int32_t map, int32_t pos)
1895 {
1896
1897 2924544 return TheMaps[map*MAPSCRS+TEMPLATE2].cset[pos];
1898 }
1899
1900 2924544 INLINE int32_t tcmbflag2(int32_t map, int32_t pos)
1901 {
1902 2924544 return TheMaps[map*MAPSCRS+TEMPLATE2].sflag[pos];
1903 }
1904
1905
1906 63 void get_questpwd(char *encrypted_pwd, int16_t pwdkey, char *pwd)
1907 {
1908 char temp_pwd[30];
1909 63 memset(temp_pwd,0,30);
1910
1911
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 8 times.
63 if(pwdkey!=0)
1912 {
1913 55 memcpy(temp_pwd,encrypted_pwd,30);
1914 55 temp_pwd[29]=0;
1915
1916
2/2
✓ Branch 0 taken 1650 times.
✓ Branch 1 taken 55 times.
1705 for(int32_t i=0; i<30; i++)
1917 {
1918 1650 temp_pwd[i] -= pwdkey;
1919 1650 int32_t t=pwdkey>>15;
1920 1650 pwdkey = (pwdkey<<1)+t;
1921 1650 }
1922 55 }
1923
1924 63 memcpy(pwd,temp_pwd,30);
1925 63 }
1926
1927
1928 192 bool devpwd()
1929 {
1930 #ifdef _DEBUG
1931 return true;
1932 #endif
1933 #if DEVLEVEL > 3
1934 return true;
1935 #endif
1936
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 return !strcmp(zc_get_config("dev","pwd","",App::zquest), (char*)clavio) || is_ci();
1937 }
1938 bool check_questpwd(zquestheader *Header, char *pwd)
1939 {
1940 if(devpwd())
1941 return true;
1942 if((!strcmp(pwd, (char*)clavio)))
1943 return true;
1944 cvs_MD5Context ctx;
1945 uint8_t md5sum[16];
1946
1947 cvs_MD5Init(&ctx);
1948 cvs_MD5Update(&ctx, (const uint8_t*)pwd, (unsigned)strlen(pwd));
1949 cvs_MD5Final(md5sum, &ctx);
1950
1951 return (memcmp(Header->pwd_hash,md5sum,16)==0);
1952 }
1953
1954 static char const* key_exts[KEYFILE_NUMTY] = {"key", "zcheat", "zpwd"};
1955 static bool key_hashed[KEYFILE_NUMTY] = {false, true, false};
1956 static char const* key_namestr[KEYFILE_NUMTY] = {"Master","Cheat","ZPwd"};
1957
1958 static bool check_keyfile(char const* path, char const* ext, bool hashed, char const* typestr, zquestheader* Header)
1959 {
1960 char keyfilename[2048];
1961 replace_extension(keyfilename, path, ext, 2047);
1962 if(!exists(keyfilename))
1963 return false;
1964 bool ret = false;
1965
1966 char password[QSTPWD_LEN] = {0}, pwd[32] = {0};
1967 PACKFILE *fp = pack_fopen_password(keyfilename, F_READ,"");
1968 char msg[80] = {0};
1969 pfread(msg, 80, fp);
1970 if(strcmp(msg,"ZQuest Auto-Generated Quest Password Key File. DO NOT EDIT!"))
1971 {
1972 zprint2("Found %s Key File '%s' (invalid header)\n", typestr, keyfilename);
1973 pack_fclose(fp);
1974 return false;
1975 }
1976 int16_t ver;
1977 byte bld;
1978 p_igetw(&ver, fp);
1979 p_getc(&bld, fp);
1980 pfread(password, QSTPWD_LEN, fp, true);
1981 if(hashed)
1982 {
1983 char unhashed_pw[QSTPWD_LEN] = {0};
1984
1985 char hashmap = 'Z';
1986 hashmap += 'Q';
1987 hashmap += 'U';
1988 hashmap += 'E';
1989 hashmap += 'S';
1990 hashmap += 'T';
1991
1992 for ( int32_t q = 0; q < QSTPWD_LEN; ++q )
1993 unhashed_pw[q] = password[q] - hashmap;
1994
1995 ret = check_questpwd(Header, unhashed_pw);
1996 }
1997 else ret = check_questpwd(Header, password);
1998 pack_fclose(fp);
1999 zprint2("Found %s Key File '%s' (%s access)\n",
2000 typestr, keyfilename, ret ? "valid" : "invalid");
2001 return ret;
2002 }
2003
2004 bool check_keyfiles(char const* path, vector<uint> types, zquestheader* Header)
2005 {
2006 char exedir[PATH_MAX] = {0};
2007 extract_name(path, exedir, FILENAMEALL);
2008 char const* paths[] = {path, exedir};
2009 for(uint keyty : types)
2010 {
2011 if(keyty >= KEYFILE_NUMTY)
2012 continue;
2013 for(char const* p : paths)
2014 {
2015 if(check_keyfile(p, key_exts[keyty], key_hashed[keyty], key_namestr[keyty], Header))
2016 return true;
2017 }
2018 }
2019 return false;
2020 }
2021
2022 290 void print_quest_metadata(zquestheader const& tempheader, char const* path, byte qst_num)
2023 {
2024 290 zprint2("\n");
2025 290 zprint2("[QUEST METADATA]\n");
2026
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 8 times.
290 if(qst_num < moduledata.max_quest_files)
2027 8 zprint2("Loading module quest %d\n", qst_num+1);
2028
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 290 times.
290 if(path) zprint2("Loading '%s'\n", path);
2029 290 zprint2("Last saved in version %s\n", tempheader.getVerStr());
2030
2031
2/2
✓ Branch 0 taken 167 times.
✓ Branch 1 taken 123 times.
290 if ( tempheader.made_in_module_name[0] ) zprint2("Created with ZC Module: %s\n\n", tempheader.made_in_module_name);
2032
2/2
✓ Branch 0 taken 167 times.
✓ Branch 1 taken 123 times.
290 if ( tempheader.new_version_devsig[0] ) zprint2("Developr Signoff by: %s\n", tempheader.new_version_devsig);
2033
2/2
✓ Branch 0 taken 167 times.
✓ Branch 1 taken 123 times.
290 if ( tempheader.new_version_compilername[0] ) zprint2("Compiled with: %s, (ID: %d)\n", tempheader.new_version_compilername, tempheader.compilerid);
2034
2/2
✓ Branch 0 taken 167 times.
✓ Branch 1 taken 123 times.
290 if ( tempheader.new_version_compilerversion[0] ) zprint2("Compiler Version: %s, (%d,%d,%d,%d)\n", tempheader.new_version_compilerversion,tempheader.compilerversionnumber_first,tempheader.compilerversionnumber_second,tempheader.compilerversionnumber_third,tempheader.compilerversionnumber_fourth);
2035
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 276 times.
290 if ( tempheader.product_name[0] ) zprint2("Project ID: %s\n", tempheader.product_name);
2036
2/2
✓ Branch 0 taken 167 times.
✓ Branch 1 taken 123 times.
290 if ( tempheader.new_version_id_date_day ) zprint2("Editor Built at date and time: %d-%d-%d at @ %s %s\n", tempheader.new_version_id_date_day, tempheader.new_version_id_date_month, tempheader.new_version_id_date_year, tempheader.build_timestamp, tempheader.build_timezone);
2037 290 zprint2("\n");
2038 290 }
2039
2040 589 int32_t readheader(PACKFILE *f, zquestheader *Header, byte printmetadata)
2041 {
2042 int32_t dummy;
2043 zquestheader tempheader;
2044 char dummybuf[80];
2045 byte temp_map_count;
2046 byte temp_midi_flags[MIDIFLAGS_SIZE];
2047 word version;
2048 char temp_pwd[30], temp_pwd2[30];
2049 int16_t temp_pwdkey;
2050 cvs_MD5Context ctx;
2051 589 memset(temp_midi_flags, 0, MIDIFLAGS_SIZE);
2052 589 memset(&tempheader, 0, sizeof(tempheader));
2053 589 memset(FFCore.quest_format, 0, sizeof(FFCore.quest_format));
2054
2055
2056
2057
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 589 times.
589 if(!pfread(tempheader.id_str,sizeof(tempheader.id_str),f)) // first read old header
2058 {
2059 Z_message("Unable to read header string\n");
2060 return qe_invalid;
2061 }
2062
2063 // check header
2064
2/2
✓ Branch 0 taken 565 times.
✓ Branch 1 taken 24 times.
589 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2065 {
2066
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(strcmp(tempheader.id_str,QH_IDSTR))
2067 {
2068 Z_message("Invalid header string: '%s' (was expecting '%s' or '%s')\n", tempheader.id_str, QH_IDSTR, QH_NEWIDSTR);
2069 return qe_invalid;
2070 }
2071 24 }
2072
2073 589 int32_t templatepath_len=0;
2074
2075 589 tempheader.external_zinfo = false;
2076 589 read_zinfo = false;
2077
2/2
✓ Branch 0 taken 565 times.
✓ Branch 1 taken 24 times.
589 if(!strcmp(tempheader.id_str,QH_IDSTR)) //pre-1.93 version
2078 {
2079 byte padding;
2080
2081
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&padding,f))
2082 {
2083 return qe_invalid;
2084 }
2085
2086
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetw(&tempheader.zelda_version,f))
2087 {
2088 return qe_invalid;
2089 }
2090
2091 24 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2092
2093
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(tempheader.zelda_version > ZELDA_VERSION)
2094 {
2095 return qe_version;
2096 }
2097
2098 24 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2099
2100
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(strcmp(tempheader.id_str,QH_IDSTR))
2101 {
2102 return qe_invalid;
2103 }
2104
2105
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(bad_version(tempheader.zelda_version))
2106 {
2107 return qe_obsolete;
2108 }
2109
2110
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetw(&tempheader.internal,f))
2111 {
2112 return qe_invalid;
2113 }
2114
2115
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&tempheader.quest_number,f))
2116 {
2117 return qe_invalid;
2118 }
2119
2120 24 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2121
2122
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!pfread(&quest_rules[0],2,f))
2123 {
2124 return qe_invalid;
2125 }
2126
2127
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&temp_map_count,f))
2128 {
2129 return qe_invalid;
2130 }
2131
2132 24 FFCore.quest_format[qMapCount] = temp_map_count;
2133
2134
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&tempheader.old_str_count,f))
2135 {
2136 return qe_invalid;
2137 }
2138
2139
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f))
2140 {
2141 return qe_invalid;
2142 }
2143
2144
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!pfread(temp_midi_flags,4,f))
2145 {
2146 return qe_invalid;
2147 }
2148
2149
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f))
2150 {
2151 return qe_invalid;
2152 }
2153
2154
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!pfread(dummybuf,14,f))
2155 {
2156 return qe_invalid;
2157 }
2158
2159
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!pfread(&quest_rules[2],2,f))
2160 {
2161 return qe_invalid;
2162 }
2163
2164
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&dummybuf,f))
2165 {
2166 return qe_invalid;
2167 }
2168
2169
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!pfread(tempheader.version,9,f))
2170 {
2171 return qe_invalid;
2172 }
2173
2174
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!pfread(tempheader.title,sizeof(tempheader.title),f))
2175 {
2176 return qe_invalid;
2177 }
2178 // These fields are expected to end in null bytes!
2179 24 tempheader.title[sizeof(tempheader.title)-1] = 0;
2180
2181
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!pfread(tempheader.author,sizeof(tempheader.author),f))
2182 {
2183 return qe_invalid;
2184 }
2185 24 tempheader.author[sizeof(tempheader.author)-1] = 0;
2186
2187
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&padding,f))
2188 {
2189 return qe_invalid;
2190 }
2191
2192
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetw(&temp_pwdkey,f))
2193 {
2194 return qe_invalid;
2195 }
2196
2197
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!pfread(temp_pwd,30,f))
2198 {
2199 return qe_invalid;
2200 }
2201
2202 24 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2203 24 cvs_MD5Init(&ctx);
2204 24 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strnlen(temp_pwd2, 30));
2205 24 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2206
2207
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(tempheader.zelda_version < 0x177) // lacks new header stuff...
2208 {
2209 //memset(tempheader.minver,0,20); // char minver[9], byte build, byte foo[10]
2210 // Not anymore...
2211 memset(tempheader.minver,0,17);
2212 tempheader.build=0;
2213 tempheader.use_keyfile=0;
2214 memset(tempheader.old_foo, 0, 9);
2215 }
2216 else
2217 {
2218
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!pfread(tempheader.minver,9,f))
2219 {
2220 return qe_invalid;
2221 }
2222
2223
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&tempheader.build,f))
2224 {
2225 return qe_invalid;
2226 }
2227
2228 24 FFCore.quest_format[vBuild] = tempheader.build;
2229
2230
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&tempheader.use_keyfile,f))
2231 {
2232 return qe_invalid;
2233 }
2234
2235
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!pfread(dummybuf,9,f))
2236 {
2237 return qe_invalid;
2238 }
2239 } // starting at minver
2240
2241
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
24 if(tempheader.zelda_version < 0x187) // lacks newer header stuff...
2242 {
2243 6 memset(&quest_rules[4],0,16); // word rules3..rules10
2244 6 }
2245 else
2246 {
2247
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!pfread(&quest_rules[4],16,f)) // read new header additions
2248 {
2249 return qe_invalid; // starting at rules3
2250 }
2251
2252
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 if(tempheader.zelda_version <= 0x190)
2253 {
2254 12 set_qr(qr_MEANPLACEDTRAPS,0);
2255 12 }
2256 }
2257 24 unpack_qrs();
2258
2259
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
30 if((tempheader.zelda_version < 0x192)||
2260
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((tempheader.zelda_version == 0x192)&&(tempheader.build<149)))
2261 {
2262 18 set_qr(qr_BRKNSHLDTILES,(get_qr(qr_BRKBLSHLDS_DEP)));
2263 18 set_bit(deprecated_rules,qr_BRKBLSHLDS_DEP,1);
2264 18 set_qr(qr_BRKBLSHLDS_DEP,1);
2265 18 }
2266
2267
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 6 times.
24 if(tempheader.zelda_version >= 0x192) // lacks newer header stuff...
2268 {
2269 6 byte *mf=temp_midi_flags;
2270
2271
3/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 4 times.
6 if((tempheader.zelda_version == 0x192)&&(tempheader.build<178))
2272 {
2273 4 mf=(byte*)dummybuf;
2274 4 }
2275
2276
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(!pfread(mf,32,f)) // read new header additions
2277 {
2278 return qe_invalid; // starting at foo2
2279 }
2280
2281
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(!pfread(dummybuf,18,f)) // read new header additions
2282 {
2283 return qe_invalid; // starting at foo2
2284 }
2285 6 }
2286
2287
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
30 if((tempheader.zelda_version < 0x192)||
2288
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((tempheader.zelda_version == 0x192)&&(tempheader.build<145)))
2289 {
2290 18 memset(tempheader.templatepath,0,2048);
2291 18 }
2292 else
2293 {
2294
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(!pfread(tempheader.templatepath,280,f)) // read templatepath
2295 {
2296 return qe_invalid;
2297 }
2298 }
2299
2300
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
30 if((tempheader.zelda_version < 0x192)||
2301
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((tempheader.zelda_version == 0x192)&&(tempheader.build<186)))
2302 {
2303 24 tempheader.use_keyfile=0;
2304 24 }
2305 24 }
2306 else
2307 {
2308 //section id
2309
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 if(!p_mgetl(&dummy,f))
2310 {
2311 return qe_invalid;
2312 }
2313
2314 //section version info
2315
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 if(!p_igetw(&version,f))
2316 {
2317 return qe_invalid;
2318 }
2319
2320 565 FFCore.quest_format[vHeader] = version;
2321
2322
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 if(!p_igetw(&dummy,f))
2323 {
2324 return qe_invalid;
2325 }
2326
2327 //section size
2328
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 if(!p_igetl(&dummy,f))
2329 {
2330 return qe_invalid;
2331 }
2332
2333 //finally... section data
2334
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 if(!p_igetw(&tempheader.zelda_version,f))
2335 {
2336 return qe_invalid;
2337 }
2338
2339 565 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2340
2341 //do some quick checking...
2342
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 565 times.
565 if(tempheader.zelda_version > ZELDA_VERSION)
2343 {
2344 return qe_version;
2345 }
2346
2347
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 565 times.
565 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2348 {
2349 return qe_invalid;
2350 }
2351
2352
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 565 times.
565 if(bad_version(tempheader.zelda_version))
2353 {
2354 return qe_obsolete;
2355 }
2356
2357
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 if(!p_getc(&tempheader.build,f))
2358 {
2359 return qe_invalid;
2360 }
2361
2362 565 FFCore.quest_format[vBuild] = tempheader.build;
2363
2364
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 526 times.
565 if(version<3)
2365 {
2366
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 if(!pfread(temp_pwd,30,f))
2367 {
2368 return qe_invalid;
2369 }
2370
2371
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 if(!p_igetw(&temp_pwdkey,f))
2372 {
2373 return qe_invalid;
2374 }
2375
2376 39 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2377 39 cvs_MD5Init(&ctx);
2378 39 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strnlen(temp_pwd2, 30));
2379 39 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2380 39 }
2381 else
2382 {
2383
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 if(!pfread(tempheader.pwd_hash,sizeof(tempheader.pwd_hash),f))
2384 {
2385 return qe_invalid;
2386 }
2387 }
2388
2389
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 if(!p_igetw(&tempheader.internal,f))
2390 {
2391 return qe_invalid;
2392 }
2393
2394
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 if(!p_getc(&tempheader.quest_number,f))
2395 {
2396 return qe_invalid;
2397 }
2398
2399 565 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2400
2401 565 size_t versz = version < 8 ? 9 : 16;
2402
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 if(!pfread(tempheader.version,versz,f))
2403 {
2404 return qe_invalid;
2405 }
2406
2407 //FFCore.quest_format[qQuestVersion] = tempheader.version;
2408 //needs to be copied as char[9] or stored as a s.str
2409
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 if(!pfread(tempheader.minver,versz,f))
2410 {
2411 return qe_invalid;
2412 }
2413
2414 //FFCore.quest_format[qMinQuestVersion] = tempheader.minver;
2415
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 if(!pfread(tempheader.title,sizeof(tempheader.title),f))
2416 {
2417 return qe_invalid;
2418 }
2419 565 tempheader.title[sizeof(tempheader.title)-1] = 0;
2420
2421
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 if(!pfread(tempheader.author,sizeof(tempheader.author),f))
2422 {
2423 return qe_invalid;
2424 }
2425 565 tempheader.author[sizeof(tempheader.author)-1] = 0;
2426
2427
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 if(!p_getc(&tempheader.use_keyfile,f))
2428 {
2429 return qe_invalid;
2430 }
2431
2432 /*
2433 if(!pfread(tempheader.data_flags,sizeof(tempheader.data_flags),f))
2434 {
2435 return qe_invalid;
2436 }
2437 */
2438
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f))
2439 {
2440 return qe_invalid;
2441 }
2442
2443
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 if(!pfread(&dummybuf,4,f))
2444 {
2445 return qe_invalid;
2446 }
2447
2448
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f))
2449 {
2450 return qe_invalid;
2451 }
2452
2453
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 if(!pfread(dummybuf,14,f))
2454 {
2455 return qe_invalid;
2456 }
2457
2458 565 templatepath_len=sizeof(tempheader.templatepath);
2459
2460
2/2
✓ Branch 0 taken 526 times.
✓ Branch 1 taken 39 times.
565 if(version==1)
2461 {
2462 39 templatepath_len=280;
2463 39 }
2464
2465
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 if(!pfread(tempheader.templatepath,templatepath_len,f))
2466 {
2467 return qe_invalid;
2468 }
2469
2470
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 if(!p_getc(&temp_map_count,f))
2471 {
2472 return qe_invalid;
2473 }
2474
2475
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 171 times.
565 if(version>=4)
2476 {
2477
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if(!p_igetl(&tempheader.version_major,f))
2478 {
2479 return qe_invalid;
2480 }
2481
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if(!p_igetl(&tempheader.version_minor,f))
2482 {
2483 return qe_invalid;
2484 }
2485
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if(!p_igetl(&tempheader.version_patch,f))
2486 {
2487 return qe_invalid;
2488 }
2489
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if(!p_igetl(&tempheader.new_version_id_fourth,f))
2490 {
2491 return qe_invalid;
2492 }
2493
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if(!p_igetl(&tempheader.new_version_id_alpha,f))
2494 {
2495 return qe_invalid;
2496 }
2497
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if(!p_igetl(&tempheader.new_version_id_beta,f))
2498 {
2499 return qe_invalid;
2500 }
2501
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if(!p_igetl(&tempheader.new_version_id_gamma,f))
2502 {
2503 return qe_invalid;
2504 }
2505
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if(!p_igetl(&tempheader.new_version_id_release,f))
2506 {
2507 return qe_invalid;
2508 }
2509
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if(!p_igetw(&tempheader.new_version_id_date_year,f))
2510 {
2511 return qe_invalid;
2512 }
2513
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if(!p_getc(&tempheader.new_version_id_date_month,f))
2514 {
2515 return qe_invalid;
2516 }
2517
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if(!p_getc(&tempheader.new_version_id_date_day,f))
2518 {
2519 return qe_invalid;
2520 }
2521
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if(!p_getc(&tempheader.new_version_id_date_hour,f))
2522 {
2523 return qe_invalid;
2524 }
2525
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if(!p_getc(&tempheader.new_version_id_date_minute,f))
2526 {
2527 return qe_invalid;
2528 }
2529
2530
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if(!pfread(tempheader.new_version_devsig,256,f))
2531 {
2532 return qe_invalid;
2533 }
2534
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if(!strcmp(tempheader.new_version_devsig, "Venrob"))
2535 strcpy(tempheader.new_version_devsig, "EmilyV99");
2536
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if(!pfread(tempheader.new_version_compilername,256,f))
2537 {
2538 return qe_invalid;
2539 }
2540
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if(!pfread(tempheader.new_version_compilerversion,256,f))
2541 {
2542 return qe_invalid;
2543 }
2544
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if(!pfread(tempheader.product_name,1024,f))
2545 {
2546 return qe_invalid;
2547 }
2548
2549
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if(!p_getc(&tempheader.compilerid,f))
2550 {
2551 return qe_invalid;
2552 }
2553
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if(!p_igetl(&tempheader.compilerversionnumber_first,f))
2554 {
2555 return qe_invalid;
2556 }
2557
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if(!p_igetl(&tempheader.compilerversionnumber_second,f))
2558 {
2559 return qe_invalid;
2560 }
2561
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if(!p_igetl(&tempheader.compilerversionnumber_third,f))
2562 {
2563 return qe_invalid;
2564 }
2565
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if(!p_igetl(&tempheader.compilerversionnumber_fourth,f))
2566 {
2567 return qe_invalid;
2568 }
2569
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if(!p_igetw(&tempheader.developerid,f))
2570 {
2571 return qe_invalid;
2572 }
2573
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if(!pfread(tempheader.made_in_module_name,1024,f))
2574 {
2575 return qe_invalid;
2576 }
2577
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if(!pfread(tempheader.build_datestamp,256,f))
2578 {
2579 return qe_invalid;
2580 }
2581
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if(!pfread(tempheader.build_timestamp,256,f))
2582 {
2583 return qe_invalid;
2584 }
2585 394 }
2586 else // <4
2587 {
2588 171 tempheader.version_major = 0;
2589 171 tempheader.version_minor = 0;
2590 171 tempheader.version_patch = 0;
2591 171 tempheader.new_version_id_fourth = 0;
2592 171 tempheader.new_version_id_alpha = 0;
2593 171 tempheader.new_version_id_beta = 0;
2594 171 tempheader.new_version_id_gamma = 0;
2595 171 tempheader.new_version_id_release = 0;
2596 171 tempheader.new_version_id_date_year = 0;
2597 171 tempheader.new_version_id_date_month = 0;
2598 171 tempheader.new_version_id_date_day = 0;
2599 171 tempheader.new_version_id_date_hour = 0;
2600 171 tempheader.new_version_id_date_minute = 0;
2601
2602 171 memset(tempheader.new_version_devsig, 0, 256);
2603 171 memset(tempheader.new_version_compilername, 0, 256);
2604 171 memset(tempheader.new_version_compilerversion, 0, 256);
2605 171 memset(tempheader.product_name, 0, 1024);
2606 171 strcpy(tempheader.product_name, "ZQuest Classic");
2607
2608 171 tempheader.compilerid = 0;
2609 171 tempheader.compilerversionnumber_first = 0;
2610 171 tempheader.compilerversionnumber_second = 0;
2611 171 tempheader.compilerversionnumber_third = 0;
2612 171 tempheader.compilerversionnumber_fourth = 0;
2613 171 tempheader.developerid = 0;
2614
2615 171 memset(tempheader.made_in_module_name, 0, 1024);
2616 171 memset(tempheader.build_datestamp, 0, 256);
2617 171 memset(tempheader.build_timestamp, 0, 256);
2618 }
2619
2620
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 171 times.
565 if ( version >= 5 )
2621 {
2622
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if(!pfread(tempheader.build_timezone,6,f))
2623 {
2624 return qe_invalid;
2625 }
2626 394 }
2627 else // < 5
2628 {
2629 171 memset(tempheader.build_timezone, 0, 6);
2630 }
2631
2/2
✓ Branch 0 taken 171 times.
✓ Branch 1 taken 394 times.
565 if ( version >= 6 )
2632 {
2633 byte b;
2634
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 394 times.
394 if(!p_getc(&b,f))
2635 {
2636 return qe_invalid;
2637 }
2638 394 tempheader.external_zinfo = b?true:false;
2639 394 read_zinfo = true;
2640 394 }
2641
2642
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 171 times.
565 if(version >= 7)
2643 {
2644
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if(!p_getc(&(tempheader.new_version_is_nightly),f))
2645 {
2646 return qe_invalid;
2647 }
2648 394 }
2649 else
2650 {
2651 171 tempheader.new_version_is_nightly = false;
2652
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 171 times.
171 if(tempheader.zelda_version < 0x255)
2653 {
2654
2/5
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 132 times.
✗ Branch 4 not taken.
171 switch(tempheader.zelda_version)
2655 {
2656 case 0x254:
2657 tempheader.version_major = 2;
2658 tempheader.version_minor = 54;
2659 break;
2660 case 0x250:
2661
7/16
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 28 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 6 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6 times.
✓ Branch 11 taken 49 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 16 times.
✓ Branch 14 taken 17 times.
✓ Branch 15 taken 10 times.
132 switch(tempheader.build)
2662 {
2663 case 19:
2664 tempheader.version_major = 2;
2665 tempheader.version_minor = 50;
2666 tempheader.new_version_id_gamma = 1;
2667 break;
2668 case 20:
2669 tempheader.version_major = 2;
2670 tempheader.version_minor = 50;
2671 tempheader.new_version_id_gamma = 2;
2672 break;
2673 case 21:
2674 tempheader.version_major = 2;
2675 tempheader.version_minor = 50;
2676 tempheader.new_version_id_gamma = 3;
2677 break;
2678 case 22:
2679 tempheader.version_major = 2;
2680 tempheader.version_minor = 50;
2681 tempheader.new_version_id_gamma = 4;
2682 break;
2683 case 23:
2684 tempheader.version_major = 2;
2685 tempheader.version_minor = 50;
2686 tempheader.new_version_id_gamma = 5;
2687 break;
2688 case 24:
2689 28 tempheader.version_major = 2;
2690 28 tempheader.version_minor = 50;
2691 28 tempheader.new_version_id_release = -1;
2692 28 break;
2693 case 25:
2694 tempheader.version_major = 2;
2695 tempheader.version_minor = 50;
2696 tempheader.version_patch = 1;
2697 tempheader.new_version_id_gamma = 1;
2698 break;
2699 case 26:
2700 6 tempheader.version_major = 2;
2701 6 tempheader.version_minor = 50;
2702 6 tempheader.version_patch = 1;
2703 6 tempheader.new_version_id_gamma = 2;
2704 6 break;
2705 case 27:
2706 tempheader.version_major = 2;
2707 tempheader.version_minor = 50;
2708 tempheader.version_patch = 1;
2709 tempheader.new_version_id_gamma = 3;
2710 break;
2711 case 28:
2712 6 tempheader.version_major = 2;
2713 6 tempheader.version_minor = 50;
2714 6 tempheader.version_patch = 1;
2715 6 tempheader.new_version_id_release = -1;
2716 6 break;
2717 case 29:
2718 49 tempheader.version_major = 2;
2719 49 tempheader.version_minor = 50;
2720 49 tempheader.version_patch = 2;
2721 49 tempheader.new_version_id_release = -1;
2722 49 break;
2723 case 30:
2724 tempheader.version_major = 2;
2725 tempheader.version_minor = 50;
2726 tempheader.version_patch = 3;
2727 tempheader.new_version_id_gamma = 1;
2728 break;
2729 case 31:
2730 16 tempheader.version_major = 2;
2731 16 tempheader.version_minor = 53;
2732 16 tempheader.new_version_id_gamma = -1;
2733 16 break;
2734 case 32:
2735 17 tempheader.version_major = 2;
2736 17 tempheader.version_minor = 53;
2737 17 tempheader.new_version_id_release = -1;
2738 17 break;
2739 case 33:
2740 10 tempheader.version_major = 2;
2741 10 tempheader.version_minor = 53;
2742 10 tempheader.version_patch = 1;
2743 10 break;
2744 }
2745 132 break;
2746
2747 case 0x211:
2748 tempheader.version_major = 2;
2749 tempheader.version_minor = 11;
2750 tempheader.new_version_id_beta = tempheader.build;
2751 break;
2752 case 0x210:
2753 39 tempheader.version_major = 2;
2754 39 tempheader.version_minor = 10;
2755 39 tempheader.new_version_id_beta = tempheader.build;
2756 39 break;
2757 }
2758 171 }
2759 }
2760
2761
2/2
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 463 times.
565 if (version>=9)
2762 {
2763 102 std::string version_string;
2764
2/4
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102 times.
✗ Branch 3 not taken.
102 if(!p_getcstr(&version_string, f))
2765 {
2766 return qe_invalid;
2767 }
2768
2769 102 strncpy(tempheader.zelda_version_string, version_string.c_str(), sizeof(tempheader.zelda_version_string));
2770 102 snprintf(tempheader.zelda_version_string, sizeof(tempheader.zelda_version_string), "%s", version_string.c_str());
2771
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 102 times.
102 }
2772 else
2773 {
2774 463 snprintf(tempheader.zelda_version_string, sizeof(tempheader.zelda_version_string), "%d.%d.%d", tempheader.version_major, tempheader.version_minor, tempheader.version_patch);
2775 }
2776
2777
3/4
✓ Branch 0 taken 557 times.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 557 times.
565 if(printmetadata || __isZQuest)
2778 {
2779 8 print_quest_metadata(tempheader, loading_qst_name, loading_qst_num);
2780 8 }
2781 }
2782
2783 //{ Version Warning
2784 589 int32_t vercmp = tempheader.compareVer();
2785 589 int32_t astatecmp = compare(int32_t(tempheader.getAlphaState()), getAlphaState());
2786 589 int32_t avercmp = compare(tempheader.getAlphaVer(), 0);
2787
4/6
✓ Branch 0 taken 589 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102 times.
✓ Branch 3 taken 487 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 102 times.
691 if(vercmp > 0 || (!vercmp &&
2788
2/4
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102 times.
✗ Branch 3 not taken.
102 (astatecmp > 0 || (!astatecmp &&
2789 102 avercmp > 0))))
2790 {
2791 bool r = true;
2792 if(loadquest_report)
2793 {
2794 enter_sys_pal();
2795 AlertDialog("Quest saved in newer version",
2796 "This quest was last saved in a newer version of ZQuest."
2797 " Attempting to load this quest may not work correctly; to"
2798 " avoid issues, try loading this quest in at least '" + std::string(tempheader.getVerStr()) + "'"
2799 "\n\nWould you like to continue loading anyway? (Not recommended)",
2800 [&](bool ret,bool)
2801 {
2802 r = ret;
2803 }).show();
2804 exit_sys_pal();
2805 }
2806 if(!r)
2807 return qe_silenterr;
2808 }
2809
1/2
✓ Branch 0 taken 589 times.
✗ Branch 1 not taken.
589 else if(tempheader.compareDate() > 0)
2810 {
2811 bool r = true;
2812 if(loadquest_report)
2813 {
2814 enter_sys_pal();
2815 AlertDialog("Quest saved in newer build",
2816 fmt::format("This quest was last saved in a newer build of ZQuest, and may have"
2817 " issues loading in this build."
2818 "\n{}"
2819 "\n\nWould you like to continue loading anyway?",
2820 tempheader.getVerCmpStr()),
2821 [&](bool ret,bool)
2822 {
2823 r = ret;
2824 }).show();
2825 exit_sys_pal();
2826 }
2827 if(!r)
2828 return qe_silenterr;
2829 }
2830 //}
2831
2832 589 read_ext_zinfo = tempheader.external_zinfo;
2833
2834 589 memcpy(Header, &tempheader, sizeof(tempheader));
2835 589 map_count=temp_map_count;
2836 589 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
2837
2838 589 unpack_qrs();
2839
2840 589 return 0;
2841 589 }
2842
2843 580 int32_t readrules(PACKFILE *f, zquestheader *Header)
2844 {
2845
2/2
✓ Branch 0 taken 557 times.
✓ Branch 1 taken 23 times.
580 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_rules);
2846
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 580 times.
580 if (should_skip)
2847 return 0;
2848
2849 int32_t dummy;
2850 zquestheader tempheader;
2851 580 word s_version=0;
2852 580 dword compatrule_version=0;
2853
2854 580 memcpy(&tempheader, Header, sizeof(tempheader));
2855
2856
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 565 times.
580 if(tempheader.zelda_version >= 0x193)
2857 {
2858 //section version info
2859
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 if(!p_igetw(&s_version,f))
2860 {
2861 return qe_invalid;
2862 }
2863
2864 565 FFCore.quest_format[vRules] = s_version;
2865
2866
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 if(!p_igetw(&dummy,f))
2867 {
2868 return qe_invalid;
2869 }
2870
2871
2/2
✓ Branch 0 taken 171 times.
✓ Branch 1 taken 394 times.
565 if(s_version > 16)
2872 {
2873
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if(!p_igetl(&compatrule_version,f))
2874 {
2875 return qe_invalid;
2876 }
2877 394 }
2878 565 FFCore.quest_format[vCompatRule] = compatrule_version;
2879
2880 //section size
2881
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 if(!p_igetl(&dummy,f))
2882 {
2883 return qe_invalid;
2884 }
2885
2886
2/2
✓ Branch 0 taken 171 times.
✓ Branch 1 taken 394 times.
565 if ( s_version < 15 )
2887 {
2888 //finally... section data
2889
1/2
✓ Branch 0 taken 171 times.
✗ Branch 1 not taken.
171 if(!pfread(quest_rules,QUESTRULES_SIZE,f))
2890 {
2891 return qe_invalid;
2892 }
2893 171 }
2894 else
2895 {
2896
2897
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if(!pfread(quest_rules,QUESTRULES_NEW_SIZE,f))
2898 {
2899 return qe_invalid;
2900 }
2901
2902 }
2903 565 }
2904
2905 //al_trace("Rules version %d\n", s_version);
2906 //{ bunch of compat stuff
2907 580 memcpy(deprecated_rules, quest_rules, QUESTRULES_NEW_SIZE);
2908
2909 580 unpack_qrs();
2910
2911
2/2
✓ Branch 0 taken 518 times.
✓ Branch 1 taken 62 times.
580 if(s_version<2)
2912 {
2913 62 set_qr(14,0);
2914 62 set_qr(27,0);
2915 62 set_qr(28,0);
2916 62 set_qr(29,0);
2917 62 set_qr(30,0);
2918 62 set_qr(32,0);
2919 62 set_qr(36,0);
2920 62 set_qr(49,0);
2921 62 set_qr(50,0);
2922 62 set_qr(51,0);
2923 62 set_qr(68,0);
2924 62 set_qr(75,0);
2925 62 set_qr(76,0);
2926 62 set_qr(98,0);
2927 62 set_qr(110,0);
2928 62 set_qr(113,0);
2929 62 set_qr(116,0);
2930 62 set_qr(102,0);
2931 62 set_qr(132,0);
2932 62 }
2933
2934 //Now, do any updates...
2935
5/6
✓ Branch 0 taken 526 times.
✓ Branch 1 taken 54 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 526 times.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 16 times.
580 if((tempheader.zelda_version < 0x211)||((tempheader.zelda_version == 0x211)&&(tempheader.build<18)))
2936 {
2937 70 set_qr(qr_SMOOTHVERTICALSCROLLING,1);
2938 70 set_qr(qr_REPLACEOPENDOORS, 1);
2939 70 set_qr(qr_OLDLENSORDER, 1);
2940 70 set_qr(qr_NOFAIRYGUYFIRES, 1);
2941 70 set_qr(qr_TRIGGERSREPEAT, 1);
2942 70 }
2943
2944
5/6
✓ Branch 0 taken 565 times.
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 565 times.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 16 times.
604 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
2945 {
2946 31 set_qr(qr_WALLFLIERS,1);
2947 31 }
2948
2949
5/6
✓ Branch 0 taken 565 times.
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 565 times.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 16 times.
604 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<4)))
2950 {
2951 31 set_qr(qr_NOBOMBPALFLASH,1);
2952 31 }
2953
2954
5/6
✓ Branch 0 taken 565 times.
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 565 times.
✓ Branch 4 taken 20 times.
✓ Branch 5 taken 20 times.
604 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
2955 {
2956 35 set_qr(qr_NOSCROLLCONTINUE,1);
2957 35 }
2958
2959
2/2
✓ Branch 0 taken 514 times.
✓ Branch 1 taken 62 times.
608 if(tempheader.zelda_version <= 0x210)
2960 {
2961 62 set_qr(qr_ARROWCLIP,1);
2962 62 }
2963
2964
2/2
✓ Branch 0 taken 537 times.
✓ Branch 1 taken 39 times.
576 if(tempheader.zelda_version == 0x210)
2965 {
2966 39 set_qr(qr_NOSCROLLCONTINUE, get_qr(qr_CMBCYCLELAYERS));
2967 39 set_qr(qr_CMBCYCLELAYERS, 0);
2968 39 set_qr(qr_CONT_SWORD_TRIGGERS, 1);
2969 39 }
2970
2971
2/2
✓ Branch 0 taken 514 times.
✓ Branch 1 taken 62 times.
576 if(tempheader.zelda_version <= 0x210)
2972 {
2973 62 set_qr(qr_OLDSTYLEWARP,1);
2974 62 set_qr(qr_210_WARPRETURN,1);
2975 62 }
2976
2977 //might not be correct
2978
2/2
✓ Branch 0 taken 553 times.
✓ Branch 1 taken 23 times.
576 if(tempheader.zelda_version < 0x210)
2979 {
2980 23 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP,1);
2981 23 set_qr(qr_OLDTRIBBLES_DEP,1);
2982 23 set_qr(qr_OLDHOOKSHOTGRAB,1);
2983 23 }
2984
2985
2/2
✓ Branch 0 taken 514 times.
✓ Branch 1 taken 62 times.
576 if(tempheader.zelda_version < 0x211)
2986 {
2987 62 set_qr(qr_WRONG_BRANG_TRAIL_DIR,1);
2988 62 }
2989
2990
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 571 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 554 times.
576 if((tempheader.zelda_version == 0x192 && tempheader.build <= 163) || tempheader.zelda_version < 0x192)
2991 {
2992 22 set_qr(qr_192b163_WARP,1);
2993 22 }
2994
2995
2/2
✓ Branch 0 taken 537 times.
✓ Branch 1 taken 39 times.
576 if(tempheader.zelda_version == 0x210)
2996 {
2997 39 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP, get_qr(qr_DMGCOMBOPRI));
2998 39 set_qr(qr_OLDTRIBBLES_DEP, get_qr(qr_DMGCOMBOPRI));
2999 39 set_qr(qr_DMGCOMBOPRI, 0);
3000 39 }
3001
3002
5/6
✓ Branch 0 taken 526 times.
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 526 times.
✓ Branch 4 taken 20 times.
✓ Branch 5 taken 20 times.
576 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build<15))
3003 {
3004 70 set_qr(qr_OLDPICKUP,1);
3005 70 }
3006
3007
5/6
✓ Branch 0 taken 526 times.
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 526 times.
✓ Branch 4 taken 20 times.
✓ Branch 5 taken 20 times.
608 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build < 18))
3008 {
3009 70 set_qr(qr_NOSOLIDDAMAGECOMBOS, 1);
3010 70 set_qr(qr_ITEMPICKUPSETSBELOW, 1); // broke around build 400
3011 70 }
3012
3013
2/2
✓ Branch 0 taken 514 times.
✓ Branch 1 taken 62 times.
608 if(tempheader.zelda_version < 0x250) // version<0x250 checks for beta 18; build was set to 18 prematurely
3014 {
3015 62 set_qr(qr_HOOKSHOTDOWNBUG, 1);
3016 62 }
3017
3018
4/4
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 444 times.
✓ Branch 2 taken 104 times.
✓ Branch 3 taken 28 times.
576 if(tempheader.zelda_version == 0x250 && tempheader.build == 24) // Annoying...
3019 {
3020 28 set_qr(qr_PEAHATCLOCKVULN, 1);
3021 28 }
3022
3023
6/6
✓ Branch 0 taken 526 times.
✓ Branch 1 taken 50 times.
✓ Branch 2 taken 132 times.
✓ Branch 3 taken 394 times.
✓ Branch 4 taken 20 times.
✓ Branch 5 taken 120 times.
576 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 22)) //22 is 2.50.0 RC4. Gotta set the door repair QR... -Dimi
3024 {
3025 70 set_qr(qr_OLD_DOORREPAIR, 1);
3026 70 }
3027
3028
6/6
✓ Branch 0 taken 526 times.
✓ Branch 1 taken 50 times.
✓ Branch 2 taken 132 times.
✓ Branch 3 taken 394 times.
✓ Branch 4 taken 20 times.
✓ Branch 5 taken 152 times.
576 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 20)) //20 is 2.50.0 RC1 and RC2 (cause it didn't get bumped). Okay I'm gonna be honest I have no idea if any 2.50 build was available before RC1, but gonna try and cover my ass here -Dimi
3029 {
3030 70 set_qr(qr_OLD_SECRETMONEY, 1);
3031 70 }
3032
3033
6/6
✓ Branch 0 taken 526 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 132 times.
✓ Branch 3 taken 394 times.
✓ Branch 4 taken 22 times.
✓ Branch 5 taken 118 times.
608 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 28)) //28 is 2.50.1 final. Potion bug might have been used, I dunno. -Dimi
3034 {
3035 104 set_qr(qr_OLD_POTION_OR_HC, 1);
3036 104 }
3037
3038
6/6
✓ Branch 0 taken 526 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 132 times.
✓ Branch 3 taken 394 times.
✓ Branch 4 taken 22 times.
✓ Branch 5 taken 118 times.
608 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<28))
3039 {
3040 104 set_qr(qr_OFFSCREENWEAPONS, 1);
3041 104 }
3042
3043 //Bombchu fix.
3044
2/2
✓ Branch 0 taken 476 times.
✓ Branch 1 taken 132 times.
608 if(tempheader.zelda_version == 0x250)
3045 {
3046
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 28 times.
132 if ( tempheader.build == 24 ) //2.50.0
3047 {
3048 28 set_qr(qr_BOMBCHUSUPERBOMB, 1);
3049 28 }
3050
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 6 times.
132 if ( tempheader.build == 28 ) //2.50.1
3051 {
3052 6 set_qr(qr_BOMBCHUSUPERBOMB, 1);
3053 6 }
3054
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 49 times.
132 if ( tempheader.build == 29 ) //2.50.2
3055 {
3056 49 set_qr(qr_BOMBCHUSUPERBOMB, 0);
3057 49 }
3058
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if ( tempheader.build == 30 ) //2.50.3RC1
3059 {
3060 set_qr(qr_BOMBCHUSUPERBOMB, 0);
3061 }
3062 132 }
3063
3064
6/6
✓ Branch 0 taken 526 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 132 times.
✓ Branch 3 taken 394 times.
✓ Branch 4 taken 28 times.
✓ Branch 5 taken 112 times.
608 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3065 {
3066 // qr_OFFSETEWPNCOLLISIONFIX
3067 // All 'official' quests need this disabled.
3068 // All 2.10 and lower quests need this enabled to preseve compatability.
3069 // All 2.11 - 2.5.1 quests should have it set also, due to a bug in about half of all the betas.
3070
3071 //~Gleeok
3072 110 set_qr(qr_OFFSETEWPNCOLLISIONFIX, 1); //This has to be set!!!!
3073
3074 // Broke in build 695
3075
3/4
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 62 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 40 times.
110 if(tempheader.zelda_version>=0x211 && tempheader.build>=18)
3076 40 set_qr(qr_BROKENSTATUES, 1);
3077 102 }
3078
11/14
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 570 times.
✓ Branch 2 taken 565 times.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 603 times.
✓ Branch 7 taken 5 times.
✓ Branch 8 taken 603 times.
✓ Branch 9 taken 5 times.
✓ Branch 10 taken 586 times.
✓ Branch 11 taken 22 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
608 if (tempheader.zelda_version <= 0x190 || (tempheader.zelda_version == 0x192 && std::string(tempheader.title).starts_with("Zelda 3000\0")))
3079 {
3080 22 set_qr(qr_COPIED_SWIM_SPRITES, 1);
3081 22 }
3082
9/10
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 476 times.
✓ Branch 2 taken 466 times.
✓ Branch 3 taken 10 times.
✓ Branch 4 taken 404 times.
✓ Branch 5 taken 62 times.
✓ Branch 6 taken 394 times.
✓ Branch 7 taken 10 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 394 times.
608 if ( (tempheader.zelda_version == 0x250 && tempheader.build < 33) || tempheader.zelda_version == 0x254 || tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3083 {
3084 204 set_qr(qr_OLD_SLASHNEXT_SECRETS, 1);
3085 204 }
3086
3087
2/2
✓ Branch 0 taken 526 times.
✓ Branch 1 taken 62 times.
588 if ( (tempheader.zelda_version < 0x211) ) //2.10 water and ladder interaction
3088 {
3089 62 set_qr(qr_OLD_210_WATER, 1);
3090 62 }
3091
3092
4/6
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 194 times.
✓ Branch 2 taken 394 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 394 times.
588 if ( (tempheader.zelda_version < 0x255 ) || (tempheader.zelda_version == 0x255 && tempheader.build < 51 ) ) //2.10 water and ladder interaction
3093 {
3094 194 set_qr(qr_STEP_IS_FLOAT,0);
3095 194 }
3096
3097
2/2
✓ Branch 0 taken 526 times.
✓ Branch 1 taken 62 times.
588 if ( tempheader.zelda_version < 0x250 )
3098 {
3099 62 set_qr(qr_8WAY_SHOT_SFX, 1);
3100 62 }
3101
3102
2/2
✓ Branch 0 taken 526 times.
✓ Branch 1 taken 62 times.
588 if(s_version < 3)
3103 {
3104 62 set_qr(qr_HOLDNOSTOPMUSIC, 1);
3105 62 set_qr(qr_CAVEEXITNOSTOPMUSIC, 1);
3106 62 }
3107
3108
2/2
✓ Branch 0 taken 526 times.
✓ Branch 1 taken 62 times.
588 if(s_version<4)
3109 {
3110 62 set_qr(10,0);
3111 62 }
3112
3113
2/2
✓ Branch 0 taken 526 times.
✓ Branch 1 taken 62 times.
588 if(s_version<5)
3114 {
3115 62 set_qr(27,0);
3116 62 }
3117
3118
2/2
✓ Branch 0 taken 526 times.
✓ Branch 1 taken 62 times.
588 if(s_version<6)
3119 {
3120 62 set_qr(46,0);
3121 62 }
3122
3123
2/2
✓ Branch 0 taken 526 times.
✓ Branch 1 taken 62 times.
588 if(s_version<7) // January 2008
3124 {
3125 62 set_qr(qr_HEARTSREQUIREDFIX,0);
3126 62 set_qr(qr_PUSHBLOCKCSETFIX,1);
3127 62 }
3128
3129
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 526 times.
588 if(s_version<8)
3130 {
3131 62 set_qr(12, 0);
3132 62 }
3133 else
3134 {
3135 526 set_bit(deprecated_rules, 12, 0);
3136 }
3137
3138
2/2
✓ Branch 0 taken 526 times.
✓ Branch 1 taken 62 times.
588 if(s_version<9) // October 2008
3139 {
3140 62 set_qr(qr_NOROPE2FLASH_DEP,0);
3141 62 set_qr(qr_NOBUBBLEFLASH_DEP,0);
3142 62 set_qr(qr_GHINI2BLINK_DEP,0);
3143 62 set_qr(qr_PHANTOMGHINI2_DEP,0);
3144 62 }
3145
3146
2/2
✓ Branch 0 taken 526 times.
✓ Branch 1 taken 62 times.
588 if(s_version<10) // December 2008
3147 {
3148 62 set_qr(qr_NOCLOCKS_DEP,0);
3149 62 set_qr(qr_ALLOW10RUPEEDROPS_DEP,0);
3150 62 }
3151
3152
2/2
✓ Branch 0 taken 526 times.
✓ Branch 1 taken 62 times.
588 if(s_version<11) // April 2009
3153 {
3154 62 set_qr(qr_SLOWENEMYANIM_DEP,0);
3155 62 }
3156
3157 // This served no purpose.
3158 // if(s_version<12) // December 2009
3159 // {
3160 // set_qr(qr_BRKBLSHLDS_DEP,0);
3161 // set_qr(qr_OLDTRIBBLES_DEP,0);
3162 // }
3163
3164 //if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 24))
3165
2/2
✓ Branch 0 taken 526 times.
✓ Branch 1 taken 62 times.
588 if(s_version < 13)
3166 {
3167 62 set_qr(qr_SHOPCHEAT, 1);
3168 62 }
3169
3170 // Not entirely sure this is the best place for this...
3171 //2.50.2 bitmap offset fix
3172 588 memset(extra_rules, 0, EXTRARULES_SIZE);
3173
6/6
✓ Branch 0 taken 526 times.
✓ Branch 1 taken 62 times.
✓ Branch 2 taken 132 times.
✓ Branch 3 taken 394 times.
✓ Branch 4 taken 40 times.
✓ Branch 5 taken 92 times.
588 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3174 {
3175 102 set_er(er_BITMAPOFFSET, 1);
3176 102 set_qr(qr_BITMAPOFFSETFIX, 1);
3177 102 }
3178 //required because quest templates also used this bit, although
3179 //it never did anything, before. -Z
3180
2/2
✓ Branch 0 taken 456 times.
✓ Branch 1 taken 132 times.
588 if ( tempheader.zelda_version == 0x250 )
3181 {
3182
5/6
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 49 times.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 67 times.
132 if( tempheader.build == 29 || tempheader.build == 30 || tempheader.build == 31 )
3183 {
3184 65 set_er(er_BITMAPOFFSET, 0);
3185 65 set_qr(qr_BITMAPOFFSETFIX, 0);
3186 65 }
3187 132 }
3188
1/2
✓ Branch 0 taken 588 times.
✗ Branch 1 not taken.
588 if ( tempheader.zelda_version == 0x254 )
3189 {
3190 set_er(er_BITMAPOFFSET, 0);
3191 set_qr(qr_BITMAPOFFSETFIX, 0);
3192 }
3193
3/4
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 194 times.
✓ Branch 2 taken 394 times.
✗ Branch 3 not taken.
588 if ( tempheader.zelda_version == 0x255 && tempheader.build < 42 ) //QR was added to 255 in this build.
3194 {
3195 set_er(er_BITMAPOFFSET, 0);
3196 set_qr(qr_BITMAPOFFSETFIX, 0);
3197 }
3198 //optimise fast drawing for older versions.
3199
4/6
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 194 times.
✓ Branch 2 taken 394 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 394 times.
588 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3200 {
3201 194 set_qr(qr_OLDSPRITEDRAWS, 1);
3202 194 }
3203 //Old eweapon->Parent (was added in 2.54, Alpha 19)
3204 //The change was made in build 43, but I'm setting this to < 42, because quests made in 42 would benefit from this change, and
3205 //older quests can set the rule by hand. We need a new qst.dat again.
3206
4/6
✓ Branch 0 taken 588 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 394 times.
✓ Branch 3 taken 194 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 394 times.
588 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3207 {
3208 set_qr(qr_OLDEWPNPARENT, 1);
3209 }
3210
4/6
✓ Branch 0 taken 588 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 394 times.
✓ Branch 3 taken 194 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 394 times.
588 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3211 {
3212 set_qr(qr_OLDCREATEBITMAP_ARGS, 1);
3213 }
3214
4/6
✓ Branch 0 taken 588 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 394 times.
✓ Branch 3 taken 194 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 394 times.
588 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 45) )
3215 {
3216 set_qr(qr_OLDQUESTMISC, 1);
3217 }
3218
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 194 times.
588 if ( tempheader.zelda_version < 0x254 )
3219 {
3220 194 set_qr(qr_OLDCREATEBITMAP_ARGS, 0);
3221 194 set_qr(qr_OLDEWPNPARENT, 0);
3222 194 set_qr(qr_OLDQUESTMISC, 0);
3223 194 }
3224
3225 //item scripts continue to run
3226
4/6
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 194 times.
✓ Branch 2 taken 394 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 394 times.
588 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3227 {
3228 194 set_qr(qr_ITEMSCRIPTSKEEPRUNNING, 0);
3229 194 set_qr(qr_SCRIPTSRUNINHEROSTEPFORWARD, 0);
3230 194 set_qr(qr_FIXSCRIPTSDURINGSCROLLING, 0);
3231 194 set_qr(qr_SCRIPTDRAWSINWARPS, 0);
3232 194 set_qr(qr_DYINGENEMYESDONTHURTHERO, 0);
3233 194 set_qr(qr_OUTOFBOUNDSENEMIES, 0);
3234 194 set_qr(qr_SPRITEXY_IS_FLOAT, 0);
3235 194 }
3236
3237
4/6
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 194 times.
✓ Branch 2 taken 394 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 394 times.
588 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3238 {
3239 194 set_qr(qr_CLEARINITDONSCRIPTCHANGE, 1);
3240 194 }
3241
4/6
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 194 times.
✓ Branch 2 taken 394 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 394 times.
588 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3242 {
3243 194 set_qr(qr_TRACESCRIPTIDS, 0);
3244 194 set_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES, 1);
3245 194 set_qr(qr_PARSER_BOOL_TRUE_DECIMAL, 1);
3246 194 set_qr(qr_PARSER_250DIVISION,1);
3247 194 set_qr(qr_PARSER_BOOL_TRUE_DECIMAL,1);
3248 194 set_qr(qr_PARSER_TRUE_INT_SIZE,0);
3249 194 set_qr(qr_PARSER_FORCE_INLINE,0);
3250 194 set_qr(qr_PARSER_BINARY_32BIT,0);
3251
2/2
✓ Branch 0 taken 187 times.
✓ Branch 1 taken 7 times.
194 if ( get_qr(qr_SELECTAWPN) )
3252 {
3253 7 set_qr(qr_NO_L_R_BUTTON_INVENTORY_SWAP,1);
3254 //In < 2.55a27, if you had an A+B subscreen, L and R didn't shift through inventory.
3255 //Now they **do**, unless you disable that behaviour.
3256 //For the sake of compatibility, old quests with the A+B subscreen rule enabed
3257 //now enable the disable L/R item swap on load.
3258 7 }
3259
3260 194 }
3261
4/6
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 194 times.
✓ Branch 2 taken 394 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 394 times.
588 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3262 {
3263 //Compatibility: Setting the hero's action to rafting was previously disallowed, though legal for scripts to attempt.
3264 194 set_qr(qr_DISALLOW_SETTING_RAFTING, 1);
3265 //Compatibility: The calculation for when to loop an animation did not factor in ASkipY correctly, resulting in
3266 //animations ending earlier than they should.
3267 194 set_qr(qr_BROKEN_ASKIP_Y_FRAMES, 1);
3268 //Enemies would ignore solidity on the top half of combos
3269 194 set_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY, 1);
3270 //Ceiling collison was a bit wonky, including hitting your head before you are near the ceiling or clipping into it slightly.
3271 194 set_qr(qr_OLD_SIDEVIEW_CEILING_COLLISON, 1);
3272 //If an itemdata had a 'frames' of 0, items created of that data would ignore all changes to 'frames'
3273 194 set_qr(qr_0AFRAME_ITEMS_IGNORE_AFRAME_CHANGES, 1);
3274 //Collision used some odd calculations before, and enemies could not be hit back into the top row or left column
3275 194 set_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION, 1);
3276 194 }
3277
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 194 times.
588 if ( tempheader.zelda_version < 0x255 )
3278 {
3279 194 set_qr(qr_NOFFCWAITDRAW, 1);
3280 194 set_qr(qr_NOITEMWAITDRAW, 1);
3281 194 set_qr(qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3282 194 set_qr(qr_OLD_INIT_SCRIPT_TIMING, 1);
3283 //set_qr(qr_DO_NOT_DEALLOCATE_INIT_AND_SAVELOAD_ARRAYS, 1);
3284 194 }
3285
4/6
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 194 times.
✓ Branch 2 taken 394 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 394 times.
588 if ( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 48 ) )
3286 {
3287 194 set_qr(qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3288 194 }
3289
4/6
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 194 times.
✓ Branch 2 taken 394 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 394 times.
588 if( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 52 ) )
3290 {
3291 194 set_qr(qr_OLD_PRINTF_ARGS, 1);
3292 194 }
3293
3294
3295
4/6
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 194 times.
✓ Branch 2 taken 394 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 394 times.
588 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 54) )
3296 {
3297 194 set_qr(qr_BROKEN_RING_POWER, 1);
3298 194 }
3299
4/6
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 194 times.
✓ Branch 2 taken 394 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 394 times.
588 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 56) )
3300 {
3301 194 set_qr(qr_NO_OVERWORLD_MAP_CHARTING, 1);
3302 194 }
3303
4/6
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 194 times.
✓ Branch 2 taken 394 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 394 times.
588 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 57) )
3304 {
3305 194 set_qr(qr_DUNGEONS_USE_CLASSIC_CHARTING, 1);
3306 194 }
3307
4/6
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 194 times.
✓ Branch 2 taken 394 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 394 times.
588 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 58) )
3308 {
3309 //Rule used to be 'qr_SETXYBUTTONITEMS', now split.
3310
1/2
✓ Branch 0 taken 194 times.
✗ Branch 1 not taken.
194 if(get_qr(qr_SET_XBUTTON_ITEMS))
3311 set_qr(qr_SET_YBUTTON_ITEMS,1);
3312 194 }
3313
4/6
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 194 times.
✓ Branch 2 taken 394 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 394 times.
588 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 59) )
3314 {
3315 194 set_qr(qr_ALLOW_EDITING_COMBO_0,1);
3316 194 }
3317
4/6
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 194 times.
✓ Branch 2 taken 394 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 394 times.
588 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 60) )
3318 {
3319 194 set_qr(qr_OLD_CHEST_COLLISION,1);
3320 194 }
3321
3322
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 194 times.
588 if ( tempheader.zelda_version < 0x254 )
3323 {
3324 194 set_qr(qr_250WRITEEDEFSCRIPT, 1);
3325 194 }
3326 //Sideview spikes in 2.50.0
3327
6/6
✓ Branch 0 taken 526 times.
✓ Branch 1 taken 62 times.
✓ Branch 2 taken 132 times.
✓ Branch 3 taken 394 times.
✓ Branch 4 taken 34 times.
✓ Branch 5 taken 98 times.
588 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<27)) //2.50.1RC3
3328 {
3329 96 set_qr(qr_OLDSIDEVIEWSPIKES, 1);
3330 96 }
3331 //more 2.50 fixes -Z
3332
6/6
✓ Branch 0 taken 526 times.
✓ Branch 1 taken 62 times.
✓ Branch 2 taken 132 times.
✓ Branch 3 taken 394 times.
✓ Branch 4 taken 89 times.
✓ Branch 5 taken 43 times.
588 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<31))
3333 {
3334 151 set_qr(qr_MELEEMAGICCOST, 0);
3335 151 set_qr(qr_GANONINTRO, 0); //This will get flipped later on in the compatrule 11 check. That's why it's turning it off.
3336 151 set_qr(qr_OLDMIRRORCOMBOS, 1);
3337 151 set_qr(qr_BROKENBOOKCOST, 1);
3338 151 set_qr(qr_BROKENCHARINTDRAWING, 1);
3339
3340 151 }
3341
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 588 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
588 if(tempheader.zelda_version == 0x254 && tempheader.build<41)
3342 {
3343 //set_qr(qr_MELEEMAGICCOST, get_er(er_MAGICCOSTSWORD));
3344 set_qr(qr_MELEEMAGICCOST, 1);
3345 }
3346
3347
2/2
✓ Branch 0 taken 565 times.
✓ Branch 1 taken 23 times.
588 if(tempheader.zelda_version < 0x193)
3348 {
3349 23 set_qr(qr_SHORTDGNWALK, 1);
3350 23 }
3351
3352
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 194 times.
588 if(tempheader.zelda_version < 0x255)
3353 {
3354 194 set_qr(qr_OLDINFMAGIC, 1);
3355 194 }
3356
3357
2/2
✓ Branch 0 taken 526 times.
✓ Branch 1 taken 62 times.
588 if((tempheader.zelda_version < 0x250)) //2.10 and earlier allowed the triforce to Warp Player out of Item Cellars in Dungeons. -Z (15th March, 2019 )
3358 {
3359 62 set_qr(qr_SIDEVIEWTRIFORCECELLAR,1);
3360 62 }
3361
3362
4/6
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 194 times.
✓ Branch 2 taken 394 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 394 times.
588 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3363 {
3364 194 set_qr(qr_OLD_F6,1);
3365 194 }
3366
4/6
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 194 times.
✓ Branch 2 taken 394 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 394 times.
588 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 49) )
3367 {
3368 194 set_qr(qr_NO_OVERWRITING_HOPPING,1);
3369 194 }
3370
4/6
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 194 times.
✓ Branch 2 taken 394 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 394 times.
588 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3371 {
3372 194 set_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT,1);
3373 194 }
3374
4/6
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 194 times.
✓ Branch 2 taken 394 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 394 times.
588 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 53) )
3375 {
3376 194 set_qr(qr_BROKEN_OVERWORLD_MINIMAP,1);
3377 194 }
3378 //}
3379
3380
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 194 times.
588 if(compatrule_version < 1) //Enemies->Secret only affects flag 16-31
3381 194 set_qr(qr_ENEMIES_SECRET_ONLY_16_31,1);
3382
3383
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 194 times.
588 if(compatrule_version < 2) //Old CSet2 Handling
3384 194 set_qr(qr_OLDCS2,1);
3385
3386
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 194 times.
588 if(compatrule_version < 3) //Hardcoded Shadow/Spawn/Death anim frames
3387 194 set_qr(qr_HARDCODED_ENEMY_ANIMS,1);
3388
3389
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 194 times.
588 if(compatrule_version < 4) //Hardcoded Shadow/Spawn/Death anim frames
3390 194 set_qr(qr_OLD_ITEMDATA_SCRIPT_TIMING,1);
3391
3392
4/4
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 394 times.
✓ Branch 2 taken 62 times.
✓ Branch 3 taken 132 times.
588 if(compatrule_version < 5 && tempheader.zelda_version >= 0x250) //Hardcoded Shadow/Spawn/Death anim frames
3393 132 set_qr(qr_NO_LANMOLA_RINGLEADER,1);
3394
3395
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 194 times.
588 if(compatrule_version < 6) //Step->Secret (Temp) only affects flag 16-31
3396 194 set_qr(qr_STEPTEMP_SECRET_ONLY_16_31,1);
3397
3398
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 194 times.
588 if(compatrule_version < 7) //'Hit All Triggers->Perm Secret' doesn't trigger temp secrets
3399 194 set_qr(qr_ALLTRIG_PERMSEC_NO_TEMP,1);
3400
3401
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 194 times.
588 if(compatrule_version < 8) //Hardcoded LItem/Bomb/Clock/Magic Tile Mods
3402 194 set_qr(qr_HARDCODED_LITEM_LTMS,1);
3403
3404
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 194 times.
588 if(compatrule_version < 9)
3405 {
3406 //Hardcoded BS Patras
3407 194 set_qr(qr_HARDCODED_BS_PATRA,1);
3408 //Hardcoded Patra Inner Eye offsets
3409 194 set_qr(qr_PATRAS_USE_HARDCODED_OFFSETS,1);
3410 //Broken 'Big enemy' animation style
3411 194 set_qr(qr_BROKEN_BIG_ENEMY_ANIMATION,1);
3412 //Broken Attribute 31/32
3413 194 set_qr(qr_BROKEN_ATTRIBUTE_31_32,1);
3414 194 }
3415
3416
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 194 times.
588 if(compatrule_version < 10) //Shared candle use limits
3417 194 set_qr(qr_CANDLES_SHARED_LIMIT,1);
3418
3419
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 194 times.
588 if(compatrule_version < 11) //No cross-screen return points
3420 194 set_qr(qr_OLD_RESPAWN_POINTS,1);
3421
3422
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 194 times.
588 if(compatrule_version < 12)
3423 {
3424 //Old fire trail duration
3425 194 set_qr(qr_OLD_FLAMETRAIL_DURATION,1);
3426 //Old Intro String in Ganon Room Behavior
3427
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 194 times.
194 if(get_qr(qr_GANONINTRO)) set_qr(qr_GANONINTRO,0);
3428 194 else set_qr(qr_GANONINTRO,1);
3429 194 }
3430
3431
3/4
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 394 times.
✓ Branch 2 taken 194 times.
✗ Branch 3 not taken.
588 if(compatrule_version < 13 && tempheader.zelda_version >= 0x255) //ANone doesn't reset to originaltile
3432 set_qr(qr_ANONE_NOANIM,1);
3433
3434
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 194 times.
588 if(compatrule_version < 14) //Old Bridge Combo Behavior
3435 194 set_qr(qr_OLD_BRIDGE_COMBOS,1);
3436
3437
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 194 times.
588 if(compatrule_version < 15) //Broken Z3 Animation
3438 194 set_qr(qr_BROKEN_Z3_ANIMATION,1);
3439
3440
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 194 times.
588 if(compatrule_version < 16) //Old Enemy Tile Behavior with Animation (None) Enemies
3441 194 set_qr(qr_OLD_TILE_INITIALIZATION,1);
3442
3443
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 194 times.
588 if(compatrule_version < 17)
3444 {
3445 //Old Quake/DrawYOffset behavior
3446 //set_qr(qr_OLD_DRAWOFFSET,1);
3447 //I'm leaving this commented cause I doubt it'll break anything and I think the bugfix might be appreciated in older versions.
3448 //On the offchance that it *does* break old quests, fixing it is as simple as uncommenting the set_bit above.
3449 194 }
3450
3451
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 194 times.
588 if(compatrule_version < 18)
3452 {
3453 //Broken DrawScreen Derivative Functions
3454 194 set_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS,1);
3455 //Scrolling Cancels Charge
3456 194 set_qr(qr_SCROLLING_KILLS_CHARGE,1);
3457 194 }
3458
3459
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 194 times.
588 if(compatrule_version < 19) //Broken Enemy Item Carrying with Large Enemies
3460 194 set_qr(qr_BROKEN_ITEM_CARRYING,1);
3461
3462
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 194 times.
588 if(compatrule_version < 20)
3463 194 set_qr(qr_CUSTOMWEAPON_IGNORE_COST,1);
3464
3465
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 194 times.
588 if(compatrule_version < 21)
3466 {
3467 194 set_qr(qr_LEEVERS_DONT_OBEY_STUN,1);
3468 194 set_qr(qr_GANON_CANT_SPAWN_ON_CONTINUE,1);
3469 194 set_qr(qr_WIZZROBES_DONT_OBEY_STUN,1);
3470 194 set_qr(qr_OLD_BUG_NET,1);
3471 194 set_qr(qr_MANHANDLA_BLOCK_SFX,1);
3472 194 }
3473
3474
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 194 times.
588 if(compatrule_version < 22)
3475 194 set_qr(qr_BROKEN_KEEPOLD_FLAG,1);
3476
3477
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 194 times.
588 if(compatrule_version < 23)
3478 194 set_qr(qr_OLD_HALF_MAGIC,1);
3479
3480
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 194 times.
588 if(compatrule_version < 24)
3481 {
3482 194 set_qr(qr_WARPS_RESTART_DMAPSCRIPT,1);
3483 194 set_qr(qr_DMAP_0_CONTINUE_BUG,1);
3484 194 }
3485
3486
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 194 times.
588 if(compatrule_version < 25)
3487 {
3488
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 194 times.
194 if (get_qr(qr_OLD_FAIRY_LIMIT)) set_qr(qr_OLD_FAIRY_LIMIT,0);
3489 194 else set_qr(qr_OLD_FAIRY_LIMIT,1);
3490 194 set_qr(qr_OLD_SCRIPTED_KNOCKBACK,1);
3491 194 }
3492
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 194 times.
588 if(compatrule_version < 26)
3493 {
3494 194 set_qr(qr_OLD_KEESE_Z_AXIS,1);
3495 194 set_qr(qr_POLVIRE_NO_SHADOW,1);
3496 194 set_qr(qr_SUBSCR_OLD_SELECTOR,1);
3497 194 }
3498
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 194 times.
588 if(compatrule_version < 27) //Noticed some junk data in the QR array...
3499 {
3500
2/2
✓ Branch 0 taken 58394 times.
✓ Branch 1 taken 194 times.
58588 for(auto q = qr_POLVIRE_NO_SHADOW+1; q < qr_PARSER_250DIVISION; ++q)
3501 58394 set_qr(q,0);
3502
2/2
✓ Branch 0 taken 388 times.
✓ Branch 1 taken 194 times.
582 for(auto q = qr_COMBODATA_INITD_MULT_TENK+1; q < qr_MAX; ++q)
3503 388 set_qr(q,0);
3504 //This should nuke any remaining junk data... not sure if it affected anything previous. -Em
3505 194 }
3506
2/2
✓ Branch 0 taken 389 times.
✓ Branch 1 taken 199 times.
588 if(compatrule_version < 28)
3507 199 set_qr(qr_SUBSCR_BACKWARDS_ID_ORDER,1);
3508
2/2
✓ Branch 0 taken 389 times.
✓ Branch 1 taken 199 times.
588 if(compatrule_version < 29)
3509 199 set_qr(qr_OLD_LOCKBLOCK_COLLISION,1);
3510
2/2
✓ Branch 0 taken 389 times.
✓ Branch 1 taken 199 times.
588 if(compatrule_version < 30)
3511 {
3512 199 set_qr(qr_DECO_2_YOFFSET,1);
3513 199 set_qr(qr_SCREENSTATE_80s_BUG,1);
3514 199 }
3515
2/2
✓ Branch 0 taken 389 times.
✓ Branch 1 taken 199 times.
588 if(compatrule_version < 31)
3516 {
3517 199 set_qr(qr_GOHMA_UNDAMAGED_BUG,1);
3518 199 set_qr(qr_FFCPRELOAD_BUGGED_LOAD,1);
3519 199 }
3520
2/2
✓ Branch 0 taken 389 times.
✓ Branch 1 taken 199 times.
588 if(compatrule_version < 32)
3521 199 set_qr(qr_BROKEN_GETPIXEL_VALUE,1);
3522
2/2
✓ Branch 0 taken 389 times.
✓ Branch 1 taken 199 times.
588 if(compatrule_version < 33)
3523 199 set_qr(qr_NO_LIFT_SPRITE,1);
3524
2/2
✓ Branch 0 taken 389 times.
✓ Branch 1 taken 199 times.
588 if(compatrule_version < 34)
3525 {
3526 199 set_qr(qr_OLD_SIDEVIEW_LANDING_CODE,1);
3527 199 set_qr(qr_OLD_FFC_SPEED_CAP,1);
3528 199 set_qr(qr_OLD_FFC_FUNCTIONALITY,1);
3529 199 set_qr(qr_OLD_WIZZROBE_SUBMERGING,1);
3530 199 }
3531
2/2
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 201 times.
588 if(compatrule_version < 35)
3532 {
3533 201 set_qr(qr_ZS_NO_NEG_ARRAY,1);
3534 201 set_qr(qr_BROKEN_INPUT_DOWN_STATE,1);
3535 201 }
3536
2/2
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 201 times.
588 if(compatrule_version < 36)
3537 201 set_qr(qr_OLD_SHALLOW_SFX,1);
3538
2/2
✓ Branch 0 taken 383 times.
✓ Branch 1 taken 205 times.
588 if(compatrule_version < 37)
3539 205 set_qr(qr_SPARKLES_INHERIT_PROPERTIES,1);
3540
2/2
✓ Branch 0 taken 383 times.
✓ Branch 1 taken 205 times.
588 if(compatrule_version < 38)
3541 205 set_qr(qr_BUGGED_LAYERED_FLAGS,1);
3542
2/2
✓ Branch 0 taken 383 times.
✓ Branch 1 taken 205 times.
588 if(compatrule_version < 39)
3543 205 set_qr(qr_HARDCODED_FFC_BUSH_DROPS,1);
3544
2/2
✓ Branch 0 taken 383 times.
✓ Branch 1 taken 205 times.
588 if(compatrule_version < 40)
3545 205 set_qr(qr_MOVINGBLOCK_FAKE_SOLID,1);
3546
2/2
✓ Branch 0 taken 381 times.
✓ Branch 1 taken 207 times.
588 if(compatrule_version < 41)
3547 207 set_qr(qr_BROKENHITBY,1);
3548
2/2
✓ Branch 0 taken 381 times.
✓ Branch 1 taken 207 times.
588 if(compatrule_version < 42)
3549 207 set_qr(qr_BROKEN_MOVING_BOMBS,1);
3550
2/2
✓ Branch 0 taken 381 times.
✓ Branch 1 taken 207 times.
588 if(compatrule_version < 43)
3551 207 set_qr(qr_OLD_BOMB_HITBOXES,1);
3552
2/2
✓ Branch 0 taken 381 times.
✓ Branch 1 taken 207 times.
588 if(compatrule_version < 44)
3553 207 set_qr(qr_SCROLLWARP_NO_RESET_FRAME,1);
3554
2/2
✓ Branch 0 taken 381 times.
✓ Branch 1 taken 207 times.
588 if(compatrule_version < 45)
3555 207 set_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME,1);
3556
2/2
✓ Branch 0 taken 381 times.
✓ Branch 1 taken 207 times.
588 if(compatrule_version < 46)
3557 207 set_qr(qr_BROKEN_RAFT_SCROLL,1);
3558
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 212 times.
588 if(compatrule_version < 47)
3559 {
3560 212 set_qr(qr_SENSITIVE_SOLID_DAMAGE,1);
3561 212 set_qr(qr_OLD_CONVEYOR_COLLISION,1);
3562 212 }
3563
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 212 times.
588 if(compatrule_version < 48)
3564 212 set_qr(qr_OLD_GUY_HANDLING,1);
3565
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 212 times.
588 if(compatrule_version < 49)
3566 212 set_qr(qr_FAIRY_FLAG_COMPAT,1);
3567
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 212 times.
588 if(compatrule_version < 50)
3568 212 set_qr(qr_OLD_LENS_LAYEREFFECT,1);
3569
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 212 times.
588 if(compatrule_version < 51)
3570 212 set_qr(qr_PUSHBLOCK_SPRITE_LAYER,1);
3571
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 212 times.
588 if (compatrule_version < 52)
3572 212 set_qr(qr_OLD_SCRIPT_VOLUME, 1);
3573
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 212 times.
588 if(compatrule_version < 53)
3574 {
3575 212 set_qr(qr_OLD_SUBSCR,1);
3576 212 set_qr(qr_ITM_0_INVIS_ON_BTNS,1);
3577 212 set_qr(qr_OLD_GAUGE_TILE_LAYOUT,1);
3578 212 }
3579
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 212 times.
588 if(compatrule_version < 54)
3580 212 set_qr(qr_WALKTHROUGHWALL_NO_DOORSTATE,1);
3581
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 212 times.
588 if(compatrule_version < 55)
3582 212 set_qr(qr_SPOTLIGHT_IGNR_SOLIDOBJ,1);
3583
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 212 times.
588 if(compatrule_version < 56)
3584 212 set_qr(qr_BROKEN_LIGHTBEAM_HITBOX,1);
3585
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 212 times.
588 if(compatrule_version < 57)
3586 212 set_qr(qr_BROKEN_SWORD_SPIN_TRIGGERS,1);
3587
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 212 times.
588 if(compatrule_version < 58)
3588 212 set_qr(qr_OLD_DMAP_INTRO_STRINGS,1);
3589
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 212 times.
588 if(compatrule_version < 59)
3590 212 set_qr(qr_SCRIPT_CONTHP_IS_HEARTS,1);
3591
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 212 times.
588 if(compatrule_version < 60)
3592 212 set_qr(qr_SEPARATE_BOMBABLE_TAPPING_SFX,1);
3593
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 212 times.
588 if(compatrule_version < 61)
3594 212 set_qr(qr_BROKEN_BOMB_AMMO_COSTS,1);
3595
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 212 times.
588 if(compatrule_version < 62)
3596 212 set_qr(qr_OLD_BROKEN_WARPEX_MUSIC,1);
3597
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 212 times.
588 if(compatrule_version < 63)
3598 {
3599 212 set_qr(qr_BROKEN_LIFTSWIM,1);
3600 212 set_qr(qr_BROKEN_GENERIC_PUSHBLOCK_LOCKING,1);
3601 212 }
3602
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 212 times.
588 if(compatrule_version < 64)
3603 212 set_qr(qr_BROKEN_FLAME_ARROW_REFLECTING,1);
3604
2/2
✓ Branch 0 taken 364 times.
✓ Branch 1 taken 224 times.
588 if(compatrule_version < 65)
3605 224 set_qr(qr_BROKEN_SIDEVIEW_SPRITE_JUMP,1);
3606
2/2
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 486 times.
588 if(compatrule_version < 66)
3607 486 set_qr(qr_NEWDARK_TRANS_STACKING,1);
3608
2/2
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 486 times.
588 if(compatrule_version < 67)
3609 486 set_qr(qr_OLD_HERO_WARP_RETSQUARE,1);
3610
3611 588 set_qr(qr_ANIMATECUSTOMWEAPONS,0);
3612
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 194 times.
588 if (s_version < 16)
3613 194 set_qr(qr_BROKEN_HORIZONTAL_WEAPON_ANIM,1);
3614
3615 588 memcpy(Header, &tempheader, sizeof(tempheader));
3616
3617 588 return 0;
3618 588 }
3619
3620 4895015 void init_msgstr(MsgStr *str)
3621 {
3622 4895015 str->s = "";
3623 4895015 str->s.shrink_to_fit();
3624 4895015 str->nextstring=0;
3625 4895015 str->tile=0;
3626 4895015 str->cset=0;
3627 4895015 str->trans=false;
3628 4895015 str->font=font_zfont;
3629 4895015 str->y=32;
3630 4895015 str->sfx=18;
3631 4895015 str->listpos=0;
3632 4895015 str->x=24;
3633 4895015 str->w=get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 24*8 : 26*8;
3634 4895015 str->h=get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 3*8 : 5*8;
3635 4895015 str->hspace=0;
3636 4895015 str->vspace=0;
3637 4895015 str->stringflags=0;
3638 4895015 str->margins[up] = 8;
3639 4895015 str->margins[down] = 0;
3640 4895015 str->margins[left] = 8;
3641 4895015 str->margins[right] = 0;
3642 4895015 str->portrait_tile = 0;
3643 4895015 str->portrait_cset = 0;
3644 4895015 str->portrait_x = 0;
3645 4895015 str->portrait_y = 0;
3646 4895015 str->portrait_tw = 1;
3647 4895015 str->portrait_th = 1;
3648 4895015 str->shadow_type = 0;
3649 4895015 str->shadow_color = 0;
3650 4895015 str->drawlayer = 6;
3651 4895015 }
3652
3653 588 void init_msgstrings(int32_t start, int32_t end)
3654 {
3655
2/4
✓ Branch 0 taken 588 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 588 times.
588 if(end <= start || end-start > msg_strings_size)
3656 return;
3657
3658
2/2
✓ Branch 0 taken 4816896 times.
✓ Branch 1 taken 588 times.
4817484 for(int32_t i=start; i<end; i++)
3659 {
3660 4816896 init_msgstr(&MsgStrings[i]);
3661 4816896 MsgStrings[i].listpos=i;
3662 4816896 }
3663
3664
1/2
✓ Branch 0 taken 588 times.
✗ Branch 1 not taken.
588 if(start==0)
3665 {
3666 588 MsgStrings[0].s = "(None)";
3667 588 MsgStrings[0].listpos = 0;
3668 588 }
3669 588 }
3670
3671 589 int32_t readstrings(PACKFILE *f, zquestheader *Header)
3672 {
3673
2/2
✓ Branch 0 taken 565 times.
✓ Branch 1 taken 24 times.
589 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_strings);
3674
3675 589 MsgStr tempMsgString;
3676
1/2
✓ Branch 0 taken 589 times.
✗ Branch 1 not taken.
589 init_msgstr(&tempMsgString);
3677
3678 589 word temp_msg_count=0;
3679 word temp_expansion[16];
3680 589 memset(temp_expansion, 0, 16*sizeof(word));
3681 589 char buf[8193] = {0};
3682
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 565 times.
589 if(Header->zelda_version < 0x193)
3683 {
3684 byte tempbyte;
3685 24 int32_t strings_to_read=0;
3686
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 1 times.
24 if (!should_skip)
3687
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_OLD_STRING_EDITOR_MARGINS,true);
3688
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
30 if((Header->zelda_version < 0x192)||
3689
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((Header->zelda_version == 0x192)&&(Header->build<31)))
3690 {
3691 18 strings_to_read=128;
3692 18 temp_msg_count=Header->old_str_count;
3693
3694 // Some sort of string count corruption seems to be common in old quests
3695
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(temp_msg_count>128)
3696 {
3697 temp_msg_count=128;
3698 }
3699 18 }
3700
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 else if((Header->zelda_version == 0x192)&&(Header->build<140))
3701 {
3702 strings_to_read=255;
3703 temp_msg_count=Header->old_str_count;
3704 }
3705 else
3706 {
3707
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!p_igetw(&temp_msg_count,f))
3708 {
3709 return qe_invalid;
3710 }
3711
3712 6 strings_to_read=temp_msg_count;
3713
3714
3/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
6 if (!should_skip && temp_msg_count >= msg_strings_size)
3715 {
3716 Z_message("Reallocating string buffer...\n");
3717
3718 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3719 // return qe_nomem;
3720
3721 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3722 delete[] MsgStrings;
3723 MsgStrings = new MsgStr[MAXMSGS];
3724 msg_strings_size = MAXMSGS;
3725 for(auto q = 0; q < msg_strings_size; ++q)
3726 {
3727 MsgStrings[q].clear();
3728 }
3729 }
3730 }
3731
3732 //reset the message strings
3733
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 1 times.
24 if (!should_skip)
3734
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 init_msgstrings(0,msg_strings_size);
3735
3736
2/2
✓ Branch 0 taken 2550 times.
✓ Branch 1 taken 24 times.
2574 for(int32_t x=0; x<strings_to_read; x++)
3737 {
3738
1/2
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
2550 init_msgstr(&tempMsgString);
3739 2550 tempMsgString.listpos = x;
3740
3741
2/4
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2550 times.
✗ Branch 3 not taken.
2550 if(!pfread(buf,73,f))
3742 {
3743 return qe_invalid;
3744 }
3745
3746 2550 buf[74] = '\0';
3747
1/2
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
2550 tempMsgString.s = buf;
3748
3749
2/4
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2550 times.
✗ Branch 3 not taken.
2550 if(!p_getc(&tempbyte,f))
3750 {
3751 return qe_invalid;
3752 }
3753
3754
3/4
✓ Branch 0 taken 246 times.
✓ Branch 1 taken 2304 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 246 times.
2796 if((Header->zelda_version < 0x192)||
3755
1/2
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
246 ((Header->zelda_version == 0x192)&&(Header->build<148)))
3756 {
3757
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2304 times.
2304 tempMsgString.nextstring=tempbyte?x+1:0;
3758
3759
2/4
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2304 times.
✗ Branch 3 not taken.
2304 if(!p_getc(&tempbyte,f))
3760 {
3761 return qe_invalid;
3762 }
3763
3764
2/4
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2304 times.
✗ Branch 3 not taken.
2304 if(!p_getc(&tempbyte,f))
3765 {
3766 return qe_invalid;
3767 }
3768 2304 }
3769 else
3770 {
3771
2/4
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 246 times.
✗ Branch 3 not taken.
246 if(!p_igetw(&tempMsgString.nextstring,f))
3772 {
3773 return qe_invalid;
3774 }
3775
3776
2/4
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 246 times.
✗ Branch 3 not taken.
246 if(!pfread(temp_expansion,32,f))
3777 {
3778 return qe_invalid;
3779 }
3780 }
3781
3782
2/2
✓ Branch 0 taken 2549 times.
✓ Branch 1 taken 1 times.
2550 if (!should_skip)
3783
1/2
✓ Branch 0 taken 2549 times.
✗ Branch 1 not taken.
2549 MsgStrings[x] = tempMsgString;
3784 2550 }
3785 24 }
3786 else
3787 {
3788 int32_t dummy_int;
3789 word s_version;
3790 word s_cversion;
3791
3792 //section version info
3793
2/4
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 565 times.
✗ Branch 3 not taken.
565 if(!p_igetw(&s_version,f))
3794 {
3795 return qe_invalid;
3796 }
3797
3798 565 FFCore.quest_format[vStrings] = s_version;
3799
3800
2/4
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 565 times.
✗ Branch 3 not taken.
565 if(!p_igetw(&s_cversion,f))
3801 {
3802 return qe_invalid;
3803 }
3804
3805 //al_trace("Strings version %d\n", s_version);
3806 //section size
3807
2/4
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 565 times.
✗ Branch 3 not taken.
565 if(!p_igetl(&dummy_int,f))
3808 {
3809 return qe_invalid;
3810 }
3811
3812 //finally... section data
3813
2/4
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 565 times.
✗ Branch 3 not taken.
565 if(!p_igetw(&temp_msg_count,f))
3814 {
3815 return qe_invalid;
3816 }
3817
3818
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 565 times.
565 if(temp_msg_count >= msg_strings_size)
3819 {
3820 Z_message("Reallocating string buffer...\n");
3821
3822 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3823 // return qe_nomem;
3824 delete[] MsgStrings;
3825 MsgStrings = new MsgStr[MAXMSGS];
3826 msg_strings_size = MAXMSGS;
3827 for(auto q = 0; q < msg_strings_size; ++q)
3828 {
3829 MsgStrings[q].clear();
3830 }
3831 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3832 }
3833
3834 //reset the message strings
3835
2/2
✓ Branch 0 taken 171 times.
✓ Branch 1 taken 394 times.
565 if(s_version < 7)
3836
1/2
✓ Branch 0 taken 171 times.
✗ Branch 1 not taken.
171 set_qr(qr_OLD_STRING_EDITOR_MARGINS,true);
3837
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 init_msgstrings(0,msg_strings_size);
3838
3839 565 int32_t string_length=(s_version<2)?73:145;
3840
3841
2/2
✓ Branch 0 taken 74980 times.
✓ Branch 1 taken 565 times.
75545 for(int32_t i=0; i<temp_msg_count; i++)
3842 {
3843
1/2
✓ Branch 0 taken 74980 times.
✗ Branch 1 not taken.
74980 init_msgstr(&tempMsgString);
3844 74980 tempMsgString.listpos = i;
3845
2/2
✓ Branch 0 taken 4120 times.
✓ Branch 1 taken 70860 times.
74980 if(s_version > 8)
3846 {
3847
2/4
✓ Branch 0 taken 4120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4120 times.
✗ Branch 3 not taken.
4120 if(!p_igetl(&string_length,f))
3848 {
3849 return qe_invalid;
3850 }
3851 4120 }
3852
3853
2/4
✓ Branch 0 taken 74980 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 74980 times.
74980 if (string_length < 0 || string_length > 8193)
3854 {
3855 return qe_invalid;
3856 }
3857
3858
2/2
✓ Branch 0 taken 74538 times.
✓ Branch 1 taken 442 times.
74980 if (string_length > 0)
3859 {
3860
2/4
✓ Branch 0 taken 74538 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 74538 times.
✗ Branch 3 not taken.
74538 if (!pfread(buf, string_length, f))
3861 {
3862 return qe_invalid;
3863 }
3864 74538 }
3865 else
3866 {
3867 442 buf[0] = 0;
3868 }
3869
3870
2/4
✓ Branch 0 taken 74980 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 74980 times.
✗ Branch 3 not taken.
74980 if(!p_igetw(&tempMsgString.nextstring,f))
3871 {
3872 return qe_invalid;
3873 }
3874
3875
2/2
✓ Branch 0 taken 26004 times.
✓ Branch 1 taken 48976 times.
74980 if(s_version<2)
3876 {
3877 26004 buf[72] = '\0';
3878
1/2
✓ Branch 0 taken 26004 times.
✗ Branch 1 not taken.
26004 tempMsgString.s = buf;
3879 26004 }
3880 else
3881 {
3882 // June 2008: A bug corrupted the last 4 chars of a string.
3883 // Discard these.
3884
1/2
✓ Branch 0 taken 48976 times.
✗ Branch 1 not taken.
48976 if(s_version<3)
3885 {
3886 for(int32_t j=140; j<144; j++)
3887 {
3888 buf[j] = '\0';
3889 }
3890 }
3891
1/2
✓ Branch 0 taken 48976 times.
✗ Branch 1 not taken.
48976 if(string_length > 8192) string_length = 8192;
3892 48976 buf[string_length]='\0'; //Force-terminate
3893
1/2
✓ Branch 0 taken 48976 times.
✗ Branch 1 not taken.
48976 tempMsgString.s = buf;
3894
3895
2/2
✓ Branch 0 taken 4120 times.
✓ Branch 1 taken 44856 times.
48976 if ( s_version >= 6 )
3896 {
3897
2/4
✓ Branch 0 taken 4120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4120 times.
✗ Branch 3 not taken.
4120 if(!p_igetl(&tempMsgString.tile,f))
3898 {
3899 return qe_invalid;
3900 }
3901 4120 }
3902 else
3903 {
3904
2/4
✓ Branch 0 taken 44856 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 44856 times.
✗ Branch 3 not taken.
44856 if(!p_igetw(&tempMsgString.tile,f))
3905 {
3906 return qe_invalid;
3907 }
3908 }
3909
3910
2/4
✓ Branch 0 taken 48976 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48976 times.
✗ Branch 3 not taken.
48976 if(!p_getc(&tempMsgString.cset,f))
3911 {
3912 return qe_invalid;
3913 }
3914
3915 byte dummy_char;
3916
3917
2/4
✓ Branch 0 taken 48976 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48976 times.
✗ Branch 3 not taken.
48976 if(!p_getc(&dummy_char,f)) // trans is stored as a char...
3918 {
3919 return qe_invalid;
3920 }
3921
3922 48976 tempMsgString.trans=dummy_char!=0;
3923
3924
2/4
✓ Branch 0 taken 48976 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48976 times.
✗ Branch 3 not taken.
48976 if(!p_getc(&tempMsgString.font,f))
3925 {
3926 return qe_invalid;
3927 }
3928
3929
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48976 times.
48976 if(s_version < 5)
3930 {
3931 if(!p_getc(&tempMsgString.y,f))
3932 {
3933 return qe_invalid;
3934 }
3935 }
3936 else
3937 {
3938
2/4
✓ Branch 0 taken 48976 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48976 times.
✗ Branch 3 not taken.
48976 if(!p_igetw(&tempMsgString.x,f))
3939 {
3940 return qe_invalid;
3941 }
3942
3943
2/4
✓ Branch 0 taken 48976 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48976 times.
✗ Branch 3 not taken.
48976 if(!p_igetw(&tempMsgString.y,f))
3944 {
3945 return qe_invalid;
3946 }
3947
3948
2/4
✓ Branch 0 taken 48976 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48976 times.
✗ Branch 3 not taken.
48976 if(!p_igetw(&tempMsgString.w,f))
3949 {
3950 return qe_invalid;
3951 }
3952
3953
2/4
✓ Branch 0 taken 48976 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48976 times.
✗ Branch 3 not taken.
48976 if(!p_igetw(&tempMsgString.h,f))
3954 {
3955 return qe_invalid;
3956 }
3957
3958
2/4
✓ Branch 0 taken 48976 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48976 times.
✗ Branch 3 not taken.
48976 if(!p_getc(&tempMsgString.hspace,f))
3959 {
3960 return qe_invalid;
3961 }
3962
3963
2/4
✓ Branch 0 taken 48976 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48976 times.
✗ Branch 3 not taken.
48976 if(!p_getc(&tempMsgString.vspace,f))
3964 {
3965 return qe_invalid;
3966 }
3967
3968
2/4
✓ Branch 0 taken 48976 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48976 times.
✗ Branch 3 not taken.
48976 if(!p_getc(&tempMsgString.stringflags,f))
3969 {
3970 return qe_invalid;
3971 }
3972 }
3973
3974
2/2
✓ Branch 0 taken 44856 times.
✓ Branch 1 taken 4120 times.
48976 if(s_version >= 7)
3975 {
3976
2/2
✓ Branch 0 taken 4120 times.
✓ Branch 1 taken 16480 times.
20600 for(int32_t q = 0; q < 4; ++q)
3977 {
3978
2/4
✓ Branch 0 taken 16480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16480 times.
✗ Branch 3 not taken.
16480 if(!p_getc(&tempMsgString.margins[q],f))
3979 {
3980 return qe_invalid;
3981 }
3982 16480 }
3983
3984
2/4
✓ Branch 0 taken 4120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4120 times.
✗ Branch 3 not taken.
4120 if(!p_igetl(&tempMsgString.portrait_tile,f))
3985 {
3986 return qe_invalid;
3987 }
3988
3989
2/4
✓ Branch 0 taken 4120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4120 times.
✗ Branch 3 not taken.
4120 if(!p_getc(&tempMsgString.portrait_cset,f))
3990 {
3991 return qe_invalid;
3992 }
3993
3994
2/4
✓ Branch 0 taken 4120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4120 times.
✗ Branch 3 not taken.
4120 if(!p_getc(&tempMsgString.portrait_x,f))
3995 {
3996 return qe_invalid;
3997 }
3998
3999
2/4
✓ Branch 0 taken 4120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4120 times.
✗ Branch 3 not taken.
4120 if(!p_getc(&tempMsgString.portrait_y,f))
4000 {
4001 return qe_invalid;
4002 }
4003
4004
2/4
✓ Branch 0 taken 4120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4120 times.
✗ Branch 3 not taken.
4120 if(!p_getc(&tempMsgString.portrait_tw,f))
4005 {
4006 return qe_invalid;
4007 }
4008
4009
2/4
✓ Branch 0 taken 4120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4120 times.
✗ Branch 3 not taken.
4120 if(!p_getc(&tempMsgString.portrait_th,f))
4010 {
4011 return qe_invalid;
4012 }
4013 4120 }
4014
4015
2/2
✓ Branch 0 taken 4120 times.
✓ Branch 1 taken 44856 times.
48976 if(s_version >= 8)
4016 {
4017
2/4
✓ Branch 0 taken 4120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4120 times.
✗ Branch 3 not taken.
4120 if(!p_getc(&tempMsgString.shadow_type,f))
4018 {
4019 return qe_invalid;
4020 }
4021
4022
2/4
✓ Branch 0 taken 4120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4120 times.
✗ Branch 3 not taken.
4120 if(!p_getc(&tempMsgString.shadow_color,f))
4023 {
4024 return qe_invalid;
4025 }
4026 4120 }
4027
4028
2/2
✓ Branch 0 taken 3811 times.
✓ Branch 1 taken 45165 times.
48976 if(s_version >= 10)
4029 {
4030
2/4
✓ Branch 0 taken 3811 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3811 times.
✗ Branch 3 not taken.
3811 if(!p_getc(&tempMsgString.drawlayer,f))
4031 {
4032 return qe_invalid;
4033 }
4034 3811 }
4035
4036
2/4
✓ Branch 0 taken 48976 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48976 times.
✗ Branch 3 not taken.
48976 if(!p_getc(&tempMsgString.sfx,f))
4037 {
4038 return qe_invalid;
4039 }
4040
4041
1/2
✓ Branch 0 taken 48976 times.
✗ Branch 1 not taken.
48976 if(s_version>3)
4042 {
4043
2/4
✓ Branch 0 taken 48976 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48976 times.
✗ Branch 3 not taken.
48976 if(!p_igetw(&tempMsgString.listpos,f))
4044 {
4045 return qe_invalid;
4046 }
4047 48976 }
4048 }
4049
4050
1/2
✓ Branch 0 taken 74980 times.
✗ Branch 1 not taken.
74980 MsgStrings[i].copyAll(tempMsgString);
4051 74980 }
4052 }
4053
4054
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 588 times.
589 if (!should_skip)
4055 588 msg_count=temp_msg_count;
4056
4057 589 return 0;
4058 589 }
4059
4060 589 int32_t readdoorcombosets(PACKFILE *f, zquestheader *Header)
4061 {
4062
2/2
✓ Branch 0 taken 565 times.
✓ Branch 1 taken 24 times.
589 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_doors);
4063
4064
3/4
✓ Branch 0 taken 571 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
595 if((Header->zelda_version < 0x192)||
4065
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 565 times.
571 ((Header->zelda_version == 0x192)&&(Header->build<158)))
4066 {
4067 18 return 0;
4068 }
4069
4070 571 word temp_door_combo_set_count=0;
4071 DoorComboSet tempDoorComboSet;
4072 word dummy_word;
4073 int32_t dummy_long;
4074 byte padding;
4075 571 int32_t s_version = 0;
4076
4077
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 570 times.
571 if (!should_skip)
4078
2/2
✓ Branch 0 taken 145920 times.
✓ Branch 1 taken 570 times.
146490 for(int32_t i=0; i<MAXDOORCOMBOSETS; i++)
4079 {
4080 145920 memset(DoorComboSets+i, 0, sizeof(DoorComboSet));
4081 146490 }
4082
4083
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 565 times.
571 if(Header->zelda_version > 0x192)
4084 {
4085 //section version info
4086
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 if(!p_igetw(&s_version,f))
4087 {
4088 return qe_invalid;
4089 }
4090
4091 565 FFCore.quest_format[vDoors] = s_version;
4092
4093 //al_trace("Door combo sets version %d\n", dummy_word);
4094
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 if(!p_igetw(&dummy_word,f))
4095 {
4096 return qe_invalid;
4097 }
4098
4099 //section size
4100
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 if(!p_igetl(&dummy_long,f))
4101 {
4102 return qe_invalid;
4103 }
4104 565 }
4105
4106 //finally... section data
4107
1/2
✓ Branch 0 taken 571 times.
✗ Branch 1 not taken.
571 if(!p_igetw(&temp_door_combo_set_count,f))
4108 {
4109 return qe_invalid;
4110 }
4111
4112
2/4
✓ Branch 0 taken 571 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 571 times.
571 if (!(temp_door_combo_set_count >= 0 && temp_door_combo_set_count <= MAXDOORCOMBOSETS))
4113 {
4114 return qe_invalid;
4115 }
4116
4117
2/2
✓ Branch 0 taken 4531 times.
✓ Branch 1 taken 571 times.
5102 for(int32_t i=0; i<temp_door_combo_set_count; i++)
4118 {
4119 4531 memset(&tempDoorComboSet, 0, sizeof(DoorComboSet));
4120
4121 //name
4122
1/2
✓ Branch 0 taken 4531 times.
✗ Branch 1 not taken.
4531 if(!pfread(&tempDoorComboSet.name,sizeof(tempDoorComboSet.name),f))
4123 {
4124 return qe_invalid;
4125 }
4126
4127
2/2
✓ Branch 0 taken 4491 times.
✓ Branch 1 taken 40 times.
4531 if(Header->zelda_version < 0x193)
4128 {
4129
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(!p_getc(&padding,f))
4130 {
4131 return qe_invalid;
4132 }
4133 40 }
4134
4135 //up door
4136
2/2
✓ Branch 0 taken 40779 times.
✓ Branch 1 taken 4531 times.
45310 for(int32_t j=0; j<9; j++)
4137 {
4138
2/2
✓ Branch 0 taken 163116 times.
✓ Branch 1 taken 40779 times.
203895 for(int32_t k=0; k<4; k++)
4139 {
4140
1/2
✓ Branch 0 taken 163116 times.
✗ Branch 1 not taken.
163116 if(!p_igetw(&tempDoorComboSet.doorcombo_u[j][k],f))
4141 {
4142 return qe_invalid;
4143 }
4144 163116 }
4145 40779 }
4146
4147
2/2
✓ Branch 0 taken 40779 times.
✓ Branch 1 taken 4531 times.
45310 for(int32_t j=0; j<9; j++)
4148 {
4149
2/2
✓ Branch 0 taken 163116 times.
✓ Branch 1 taken 40779 times.
203895 for(int32_t k=0; k<4; k++)
4150 {
4151
1/2
✓ Branch 0 taken 163116 times.
✗ Branch 1 not taken.
163116 if(!p_getc(&tempDoorComboSet.doorcset_u[j][k],f))
4152 {
4153 return qe_invalid;
4154 }
4155 163116 }
4156 40779 }
4157
4158 //down door
4159
2/2
✓ Branch 0 taken 40779 times.
✓ Branch 1 taken 4531 times.
45310 for(int32_t j=0; j<9; j++)
4160 {
4161
2/2
✓ Branch 0 taken 163116 times.
✓ Branch 1 taken 40779 times.
203895 for(int32_t k=0; k<4; k++)
4162 {
4163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 163116 times.
163116 if(!p_igetw(&tempDoorComboSet.doorcombo_d[j][k],f))
4164 {
4165 return qe_invalid;
4166 }
4167 163116 }
4168 40779 }
4169
4170
2/2
✓ Branch 0 taken 40779 times.
✓ Branch 1 taken 4531 times.
45310 for(int32_t j=0; j<9; j++)
4171 {
4172
2/2
✓ Branch 0 taken 163116 times.
✓ Branch 1 taken 40779 times.
203895 for(int32_t k=0; k<4; k++)
4173 {
4174
1/2
✓ Branch 0 taken 163116 times.
✗ Branch 1 not taken.
163116 if(!p_getc(&tempDoorComboSet.doorcset_d[j][k],f))
4175 {
4176 return qe_invalid;
4177 }
4178 163116 }
4179 40779 }
4180
4181 //left door
4182
2/2
✓ Branch 0 taken 40779 times.
✓ Branch 1 taken 4531 times.
45310 for(int32_t j=0; j<9; j++)
4183 {
4184
2/2
✓ Branch 0 taken 244674 times.
✓ Branch 1 taken 40779 times.
285453 for(int32_t k=0; k<6; k++)
4185 {
4186
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 244674 times.
244674 if(!p_igetw(&tempDoorComboSet.doorcombo_l[j][k],f))
4187 {
4188 return qe_invalid;
4189 }
4190 244674 }
4191 40779 }
4192
4193
2/2
✓ Branch 0 taken 40779 times.
✓ Branch 1 taken 4531 times.
45310 for(int32_t j=0; j<9; j++)
4194 {
4195
2/2
✓ Branch 0 taken 244674 times.
✓ Branch 1 taken 40779 times.
285453 for(int32_t k=0; k<6; k++)
4196 {
4197
1/2
✓ Branch 0 taken 244674 times.
✗ Branch 1 not taken.
244674 if(!p_getc(&tempDoorComboSet.doorcset_l[j][k],f))
4198 {
4199 return qe_invalid;
4200 }
4201 244674 }
4202 40779 }
4203
4204 //right door
4205
2/2
✓ Branch 0 taken 40779 times.
✓ Branch 1 taken 4531 times.
45310 for(int32_t j=0; j<9; j++)
4206 {
4207
2/2
✓ Branch 0 taken 244674 times.
✓ Branch 1 taken 40779 times.
285453 for(int32_t k=0; k<6; k++)
4208 {
4209
1/2
✓ Branch 0 taken 244674 times.
✗ Branch 1 not taken.
244674 if(!p_igetw(&tempDoorComboSet.doorcombo_r[j][k],f))
4210 {
4211 return qe_invalid;
4212 }
4213 244674 }
4214 40779 }
4215
4216
2/2
✓ Branch 0 taken 40779 times.
✓ Branch 1 taken 4531 times.
45310 for(int32_t j=0; j<9; j++)
4217 {
4218
2/2
✓ Branch 0 taken 244674 times.
✓ Branch 1 taken 40779 times.
285453 for(int32_t k=0; k<6; k++)
4219 {
4220
1/2
✓ Branch 0 taken 244674 times.
✗ Branch 1 not taken.
244674 if(!p_getc(&tempDoorComboSet.doorcset_r[j][k],f))
4221 {
4222 return qe_invalid;
4223 }
4224 244674 }
4225 40779 }
4226
4227 //up bomb rubble
4228
2/2
✓ Branch 0 taken 9062 times.
✓ Branch 1 taken 4531 times.
13593 for(int32_t j=0; j<2; j++)
4229 {
4230
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9062 times.
9062 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_u[j],f))
4231 {
4232 return qe_invalid;
4233 }
4234 9062 }
4235
4236
2/2
✓ Branch 0 taken 9062 times.
✓ Branch 1 taken 4531 times.
13593 for(int32_t j=0; j<2; j++)
4237 {
4238
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9062 times.
9062 if(!p_getc(&tempDoorComboSet.bombdoorcset_u[j],f))
4239 {
4240 return qe_invalid;
4241 }
4242 9062 }
4243
4244 //down bomb rubble
4245
2/2
✓ Branch 0 taken 9062 times.
✓ Branch 1 taken 4531 times.
13593 for(int32_t j=0; j<2; j++)
4246 {
4247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9062 times.
9062 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_d[j],f))
4248 {
4249 return qe_invalid;
4250 }
4251 9062 }
4252
4253
2/2
✓ Branch 0 taken 9062 times.
✓ Branch 1 taken 4531 times.
13593 for(int32_t j=0; j<2; j++)
4254 {
4255
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9062 times.
9062 if(!p_getc(&tempDoorComboSet.bombdoorcset_d[j],f))
4256 {
4257 return qe_invalid;
4258 }
4259 9062 }
4260
4261 //left bomb rubble
4262
2/2
✓ Branch 0 taken 13593 times.
✓ Branch 1 taken 4531 times.
18124 for(int32_t j=0; j<3; j++)
4263 {
4264
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13593 times.
13593 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_l[j],f))
4265 {
4266 return qe_invalid;
4267 }
4268 13593 }
4269
4270
2/2
✓ Branch 0 taken 13593 times.
✓ Branch 1 taken 4531 times.
18124 for(int32_t j=0; j<3; j++)
4271 {
4272
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13593 times.
13593 if(!p_getc(&tempDoorComboSet.bombdoorcset_l[j],f))
4273 {
4274 return qe_invalid;
4275 }
4276 13593 }
4277
4278
2/2
✓ Branch 0 taken 4491 times.
✓ Branch 1 taken 40 times.
4531 if(Header->zelda_version < 0x193)
4279 {
4280
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(!p_getc(&padding,f))
4281 {
4282 return qe_invalid;
4283 }
4284
4285 40 }
4286
4287 //right bomb rubble
4288
2/2
✓ Branch 0 taken 13593 times.
✓ Branch 1 taken 4531 times.
18124 for(int32_t j=0; j<3; j++)
4289 {
4290
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13593 times.
13593 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_r[j],f))
4291 {
4292 return qe_invalid;
4293 }
4294 13593 }
4295
4296
2/2
✓ Branch 0 taken 13593 times.
✓ Branch 1 taken 4531 times.
18124 for(int32_t j=0; j<3; j++)
4297 {
4298
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13593 times.
13593 if(!p_getc(&tempDoorComboSet.bombdoorcset_r[j],f))
4299 {
4300 return qe_invalid;
4301 }
4302 13593 }
4303
4304
2/2
✓ Branch 0 taken 4491 times.
✓ Branch 1 taken 40 times.
4531 if(Header->zelda_version < 0x193)
4305 {
4306
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(!p_getc(&padding,f))
4307 {
4308 return qe_invalid;
4309 }
4310 40 }
4311
4312 //walkthrough stuff
4313
2/2
✓ Branch 0 taken 18124 times.
✓ Branch 1 taken 4531 times.
22655 for(int32_t j=0; j<4; j++)
4314 {
4315
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18124 times.
18124 if(!p_igetw(&tempDoorComboSet.walkthroughcombo[j],f))
4316 {
4317 return qe_invalid;
4318 }
4319 18124 }
4320
4321
2/2
✓ Branch 0 taken 18124 times.
✓ Branch 1 taken 4531 times.
22655 for(int32_t j=0; j<4; j++)
4322 {
4323
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18124 times.
18124 if(!p_getc(&tempDoorComboSet.walkthroughcset[j],f))
4324 {
4325 return qe_invalid;
4326 }
4327 18124 }
4328
4329 //flags
4330
2/2
✓ Branch 0 taken 9062 times.
✓ Branch 1 taken 4531 times.
13593 for(int32_t j=0; j<2; j++)
4331 {
4332
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9062 times.
9062 if(!p_getc(&tempDoorComboSet.flags[j],f))
4333 {
4334 return qe_invalid;
4335 }
4336 9062 }
4337
4338
2/2
✓ Branch 0 taken 4491 times.
✓ Branch 1 taken 40 times.
4531 if(Header->zelda_version < 0x193)
4339 {
4340
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(!pfread(&tempDoorComboSet.expansion,sizeof(tempDoorComboSet.expansion),f))
4341 {
4342 return qe_invalid;
4343 }
4344 40 }
4345
4346
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 4517 times.
4531 if (!should_skip)
4347 4517 memcpy(&DoorComboSets[i], &tempDoorComboSet, sizeof(tempDoorComboSet));
4348 4531 }
4349
4350
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 570 times.
571 if (!should_skip)
4351 570 door_combo_set_count=temp_door_combo_set_count;
4352
4353 571 return 0;
4354 589 }
4355
4356 5 int32_t count_dmaps()
4357 {
4358 5 int32_t i=MAXDMAPS-1;
4359 5 bool found=false;
4360
4361
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 5 times.
5 while(i>=0 && !found)
4362 {
4363
4/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
15 if((DMaps[i].map!=0)||(DMaps[i].level!=0)||(DMaps[i].xoff!=0)||
4364
3/6
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
5 (DMaps[i].compass!=0)||(DMaps[i].color!=0)||(DMaps[i].midi!=0)||
4365
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 (DMaps[i].cont!=0)||(DMaps[i].type!=0))
4366 10 found=true;
4367
4368
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 10 times.
50 for(int32_t j=0; j<8; j++)
4369 {
4370
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(DMaps[i].grid[j]!=0)
4371
4372 found=true;
4373 40 }
4374
4375
5/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 5 taken 5 times.
10 if((DMaps[i].name[0]!=0)||(DMaps[i].title[0]!=0)||
4376 (DMaps[i].intro[0]!=0)||(DMaps[i].tmusic[0]!=0))
4377 15 found=true;
4378
4379
3/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
15 if((DMaps[i].minimap_1_tile!=0)||(DMaps[i].minimap_2_tile!=0)||
4380
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 (DMaps[i].largemap_1_tile!=0)||(DMaps[i].largemap_2_tile!=0)||
4381
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 (DMaps[i].minimap_1_cset!=0)||(DMaps[i].minimap_2_cset!=0)||
4382
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 (DMaps[i].largemap_1_cset!=0)||(DMaps[i].largemap_2_cset!=0))
4383 10 found=true;
4384
4385 if(!found)
4386 {
4387 i--;
4388 }
4389 }
4390
4391 5 return i+1;
4392 }
4393
4394
4395 5 int32_t count_shops(miscQdata *Misc)
4396 {
4397 5 int32_t i=NUM_SHOPS-1,j;
4398 5 bool found=false;
4399
4400
4/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1224 times.
✓ Branch 2 taken 1220 times.
✓ Branch 3 taken 5 times.
1225 while(i>=0 && !found)
4401 {
4402 1220 j=2;
4403
4404
4/4
✓ Branch 0 taken 1216 times.
✓ Branch 1 taken 3656 times.
✓ Branch 2 taken 3652 times.
✓ Branch 3 taken 1220 times.
4872 while(j>=0 && !found)
4405 {
4406
3/4
✓ Branch 0 taken 3648 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3648 times.
3652 if((Misc->shop[i].hasitem[j]!=0)||(Misc->shop[i].price[j]!=0))
4407 {
4408 4 found=true;
4409 4 }
4410 else
4411 {
4412 3648 j--;
4413 }
4414 }
4415
4416
1/2
✓ Branch 0 taken 1220 times.
✗ Branch 1 not taken.
1220 if(Misc->shop[i].name[0]!=0)
4417 {
4418 found=true;
4419 }
4420
4421
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1216 times.
1220 if(!found)
4422 {
4423 1216 i--;
4424 1216 }
4425 }
4426
4427 5 return i+1;
4428 }
4429
4430 5 int32_t count_infos(miscQdata *Misc)
4431 {
4432 5 int32_t i=255,j;
4433 5 bool found=false;
4434
4435
4/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1224 times.
✓ Branch 2 taken 1220 times.
✓ Branch 3 taken 5 times.
1225 while(i>=0 && !found)
4436 {
4437 1220 j=2;
4438
4439
4/4
✓ Branch 0 taken 1216 times.
✓ Branch 1 taken 3656 times.
✓ Branch 2 taken 3652 times.
✓ Branch 3 taken 1220 times.
4872 while(j>=0 && !found)
4440 {
4441
4/4
✓ Branch 0 taken 3651 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 3648 times.
3652 if((Misc->info[i].str[j]!=0)||(Misc->info[i].price[j]!=0))
4442 {
4443 4 found=true;
4444 4 }
4445 else
4446 {
4447 3648 j--;
4448 }
4449 }
4450
4451
1/2
✓ Branch 0 taken 1220 times.
✗ Branch 1 not taken.
1220 if(Misc->info[i].name[0]!=0)
4452 {
4453 found=true;
4454 }
4455
4456
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1216 times.
1220 if(!found)
4457 {
4458 1216 i--;
4459 1216 }
4460 }
4461
4462 5 return i+1;
4463 }
4464
4465 5 int32_t count_warprings(miscQdata *Misc)
4466 {
4467 5 int32_t i=15,j;
4468 5 bool found=false;
4469
4470
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
✓ Branch 2 taken 28 times.
✓ Branch 3 taken 5 times.
33 while(i>=0 && !found)
4471 {
4472 28 j=7;
4473
4474
4/4
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 206 times.
✓ Branch 2 taken 201 times.
✓ Branch 3 taken 28 times.
229 while(j>=0 && !found)
4475 {
4476
4/4
✓ Branch 0 taken 199 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 196 times.
201 if((Misc->warp[i].dmap[j]!=0)||(Misc->warp[i].scr[j]!=0))
4477 {
4478 5 found=true;
4479 5 }
4480 else
4481 {
4482 196 j--;
4483 }
4484 }
4485
4486
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 23 times.
28 if(!found)
4487 {
4488 23 i--;
4489 23 }
4490 }
4491
4492 5 return i+1;
4493 }
4494
4495 5 int32_t count_palcycles(miscQdata *Misc)
4496 {
4497 5 int32_t i=255,j;
4498 5 bool found=false;
4499
4500
4/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1164 times.
✓ Branch 2 taken 1161 times.
✓ Branch 3 taken 5 times.
1166 while(i>=0 && !found)
4501 {
4502 1161 j=2;
4503
4504
4/4
✓ Branch 0 taken 1158 times.
✓ Branch 1 taken 3480 times.
✓ Branch 2 taken 3477 times.
✓ Branch 3 taken 1161 times.
4638 while(j>=0 && !found)
4505 {
4506
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3474 times.
3477 if(Misc->cycles[i][j].count!=0)
4507 {
4508 3 found=true;
4509 3 }
4510 else
4511 {
4512 3474 j--;
4513 }
4514 }
4515
4516
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1158 times.
1161 if(!found)
4517 {
4518 1158 i--;
4519 1158 }
4520 }
4521
4522 5 return i+1;
4523 }
4524
4525 863381 void clear_screen(mapscr *temp_scr)
4526 {
4527 863381 temp_scr->zero_memory();
4528 863381 }
4529
4530 // NOTE: when modifying this, you need to also update:
4531 // readonedmap, readdmaps, and FFScript::read_dmaps
4532 // (and their associated write functions)
4533 3661 int32_t readdmaps(PACKFILE *f, zquestheader *Header, word, word, word start_dmap, word max_dmaps)
4534 {
4535
2/2
✓ Branch 0 taken 3637 times.
✓ Branch 1 taken 24 times.
3661 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_dmaps);
4536
4537 3661 word dmapstoread=0;
4538 3661 dmap tempDMap;
4539
4540 int32_t dummy;
4541 3661 word s_version=0, s_cversion=0;
4542 byte padding;
4543
4544 char legacy_title[22];
4545
4546
2/2
✓ Branch 0 taken 3073 times.
✓ Branch 1 taken 588 times.
3661 if (!should_skip)
4547
2/2
✓ Branch 0 taken 301056 times.
✓ Branch 1 taken 588 times.
301644 for(int32_t i=0; i<max_dmaps; i++)
4548 {
4549
1/2
✓ Branch 0 taken 301056 times.
✗ Branch 1 not taken.
301056 DMaps[start_dmap + i].clear();
4550 301056 sprintf(legacy_title," ");
4551 301056 sprintf(DMaps[start_dmap+i].intro," ");
4552 301056 DMaps[start_dmap+i].type |= dmCAVE;
4553 301644 }
4554
4555
4/4
✓ Branch 0 taken 589 times.
✓ Branch 1 taken 3072 times.
✓ Branch 2 taken 565 times.
✓ Branch 3 taken 24 times.
3661 if(!Header || Header->zelda_version > 0x192)
4556 {
4557 //section version info
4558
3/4
✓ Branch 0 taken 565 times.
✓ Branch 1 taken 3072 times.
✓ Branch 2 taken 565 times.
✗ Branch 3 not taken.
3637 if(!p_igetw(&s_version,f))
4559 {
4560 return qe_invalid;
4561 }
4562
4563 565 FFCore.quest_format[vDMaps] = s_version;
4564
4565 //al_trace("DMaps version %d\n", s_version);
4566
4567
2/4
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 565 times.
✗ Branch 3 not taken.
565 if(!p_igetw(&s_cversion,f))
4568 {
4569 return qe_invalid;
4570 }
4571
4572 //section size
4573
2/4
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 565 times.
✗ Branch 3 not taken.
565 if(!p_igetl(&dummy,f))
4574 {
4575 return qe_invalid;
4576 }
4577
4578 //finally... section data
4579
2/4
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 565 times.
✗ Branch 3 not taken.
565 if(!p_igetw(&dmapstoread,f))
4580 {
4581 return qe_invalid;
4582 }
4583 565 }
4584 else
4585 {
4586
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
30 if((Header->zelda_version < 0x192)||
4587
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((Header->zelda_version == 0x192)&&(Header->build<5)))
4588 {
4589 18 dmapstoread=32;
4590 18 }
4591
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 else if(s_version <= 4)
4592 {
4593 6 dmapstoread=OLDMAXDMAPS;
4594 6 }
4595 else
4596 {
4597 dmapstoread=MAXDMAPS;
4598 }
4599 }
4600
4601
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 526 times.
589 dmapstoread=zc_min(dmapstoread, max_dmaps);
4602
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 526 times.
589 dmapstoread=zc_min(dmapstoread, MAXDMAPS-start_dmap);
4603
4604
2/2
✓ Branch 0 taken 281408 times.
✓ Branch 1 taken 589 times.
281997 for(int32_t i=start_dmap; i<dmapstoread+start_dmap; i++)
4605 {
4606
1/2
✓ Branch 0 taken 281408 times.
✗ Branch 1 not taken.
281408 tempDMap.clear();
4607 281408 sprintf(legacy_title," ");
4608 281408 sprintf(tempDMap.intro," ");
4609
4610
2/4
✓ Branch 0 taken 281408 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 281408 times.
✗ Branch 3 not taken.
281408 if(!p_getc(&tempDMap.map,f))
4611 {
4612 return qe_invalid;
4613 }
4614
4615
2/2
✓ Branch 0 taken 12096 times.
✓ Branch 1 taken 269312 times.
281408 if(s_version <= 4)
4616 {
4617 byte tempbyte;
4618
4619
2/4
✓ Branch 0 taken 12096 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12096 times.
✗ Branch 3 not taken.
12096 if(!p_getc(&tempbyte,f))
4620 {
4621 return qe_invalid;
4622 }
4623
4624 12096 tempDMap.level=(word)tempbyte;
4625 12096 }
4626 else
4627 {
4628
2/4
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 269312 times.
✗ Branch 3 not taken.
269312 if(!p_igetw(&tempDMap.level,f))
4629 {
4630 return qe_invalid;
4631 }
4632 }
4633
4634
2/4
✓ Branch 0 taken 281408 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 281408 times.
✗ Branch 3 not taken.
281408 if(!p_getc(&tempDMap.xoff,f))
4635 {
4636 return qe_invalid;
4637 }
4638
4639
2/4
✓ Branch 0 taken 281408 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 281408 times.
✗ Branch 3 not taken.
281408 if(!p_getc(&tempDMap.compass,f))
4640 {
4641 return qe_invalid;
4642 }
4643
4644
2/2
✓ Branch 0 taken 269312 times.
✓ Branch 1 taken 12096 times.
281408 if(s_version > 8) // February 2009
4645 {
4646
2/4
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 269312 times.
✗ Branch 3 not taken.
269312 if(!p_igetw(&tempDMap.color,f))
4647 {
4648 return qe_invalid;
4649 }
4650 269312 }
4651 else
4652 {
4653 byte tempbyte;
4654
4655
2/4
✓ Branch 0 taken 12096 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12096 times.
✗ Branch 3 not taken.
12096 if(!p_getc(&tempbyte,f))
4656 {
4657 return qe_invalid;
4658 }
4659
4660 12096 tempDMap.color = (word)tempbyte;
4661 }
4662
4663
2/4
✓ Branch 0 taken 281408 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 281408 times.
✗ Branch 3 not taken.
281408 if(!p_getc(&tempDMap.midi,f))
4664 {
4665 return qe_invalid;
4666 }
4667
4668
2/4
✓ Branch 0 taken 281408 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 281408 times.
✗ Branch 3 not taken.
281408 if(!p_getc(&tempDMap.cont,f))
4669 {
4670 return qe_invalid;
4671 }
4672
4673
2/4
✓ Branch 0 taken 281408 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 281408 times.
✗ Branch 3 not taken.
281408 if(!p_getc(&tempDMap.type,f))
4674 {
4675 return qe_invalid;
4676 }
4677
4678
4/4
✓ Branch 0 taken 3443 times.
✓ Branch 1 taken 277965 times.
✓ Branch 2 taken 3399 times.
✓ Branch 3 taken 44 times.
284851 if((tempDMap.type & dmfTYPE) == dmOVERW &&
4679
1/2
✓ Branch 0 taken 3443 times.
✗ Branch 1 not taken.
3443 (!Header || Header->zelda_version >= 0x210)) // Not sure exactly when this changed
4680 3399 tempDMap.xoff = 0;
4681
4682
2/2
✓ Branch 0 taken 281408 times.
✓ Branch 1 taken 2251264 times.
2532672 for(int32_t j=0; j<8; j++)
4683 {
4684
2/4
✓ Branch 0 taken 2251264 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2251264 times.
✗ Branch 3 not taken.
2251264 if(!p_getc(&tempDMap.grid[j],f))
4685 {
4686 return qe_invalid;
4687 }
4688 2251264 }
4689
4690
5/6
✓ Branch 0 taken 281408 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 280832 times.
✓ Branch 3 taken 576 times.
✓ Branch 4 taken 1536 times.
✓ Branch 5 taken 279296 times.
281408 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<41))))
4691 {
4692
4/4
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 1975 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 127 times.
2112 if(tempDMap.level>0&&tempDMap.level<10)
4693 {
4694 127 sprintf(legacy_title,"LEVEL-%d ", tempDMap.level);
4695 127 }
4696
2/2
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 1536 times.
2112 tempDMap.title.assign(legacy_title);
4697
4698
3/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 558 times.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
576 if(i==0 && Header->zelda_version <= 0x190)
4699 {
4700
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 tempDMap.cont = std::max((int)tempDMap.cont - tempDMap.xoff, 0);
4701
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 tempDMap.compass = std::max((int)tempDMap.compass - tempDMap.xoff, 0);
4702 18 }
4703
4704 //forgotten -DD
4705
2/2
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 439 times.
576 if(tempDMap.level==0)
4706 {
4707 439 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4708 439 }
4709 576 }
4710 else
4711 {
4712
3/4
✓ Branch 0 taken 280832 times.
✓ Branch 1 taken 1536 times.
✓ Branch 2 taken 280832 times.
✗ Branch 3 not taken.
279296 if(!p_getstr(tempDMap.name,sizeof(DMaps[0].name) - 1,f))
4713 {
4714 return qe_invalid;
4715 }
4716
4717
2/2
✓ Branch 0 taken 88320 times.
✓ Branch 1 taken 192512 times.
280832 if(s_version<20)
4718 {
4719
2/4
✓ Branch 0 taken 88320 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 88320 times.
✗ Branch 3 not taken.
88320 if (!p_getstr(legacy_title, sizeof(legacy_title) - 1, f))
4720 {
4721 return qe_invalid;
4722 }
4723
1/2
✓ Branch 0 taken 88320 times.
✗ Branch 1 not taken.
88320 tempDMap.title.assign(legacy_title);
4724 88320 }
4725 else
4726 {
4727
2/4
✓ Branch 0 taken 192512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 192512 times.
✗ Branch 3 not taken.
192512 if (!p_getwstr(&tempDMap.title, f))
4728 {
4729 return qe_invalid;
4730 }
4731 }
4732
4733
2/4
✓ Branch 0 taken 280832 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 280832 times.
✗ Branch 3 not taken.
280832 if(!p_getstr(tempDMap.intro,sizeof(DMaps[0].intro)-1,f))
4734 {
4735 return qe_invalid;
4736 }
4737
4738
5/8
✓ Branch 0 taken 280832 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 280832 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1536 times.
✓ Branch 5 taken 279296 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1536 times.
280832 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<152))))
4739 {
4740 if ((tempDMap.type & dmfTYPE) == dmOVERW) tempDMap.flags = dmfCAVES | dmf3STAIR | dmfWHIRLWIND | dmfGUYCAVES;
4741 DMaps[i] = tempDMap;
4742
4743 continue;
4744 }
4745
4746
3/4
✓ Branch 0 taken 280832 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 279296 times.
280832 if(Header && (Header->zelda_version < 0x193))
4747 {
4748
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4749 {
4750 return qe_invalid;
4751 }
4752 1536 }
4753
2/2
✓ Branch 0 taken 201728 times.
✓ Branch 1 taken 79104 times.
280832 if ( s_version >= 11 )
4754 {
4755
2/4
✓ Branch 0 taken 201728 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 201728 times.
✗ Branch 3 not taken.
201728 if(!p_igetl(&tempDMap.minimap_1_tile,f))
4756 {
4757 return qe_invalid;
4758 }
4759 201728 }
4760 else
4761 {
4762
2/4
✓ Branch 0 taken 79104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 79104 times.
✗ Branch 3 not taken.
79104 if(!p_igetw(&tempDMap.minimap_1_tile,f))
4763 {
4764 return qe_invalid;
4765 }
4766 }
4767
4768
2/4
✓ Branch 0 taken 280832 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 280832 times.
✗ Branch 3 not taken.
280832 if(!p_getc(&tempDMap.minimap_1_cset,f))
4769 {
4770 return qe_invalid;
4771 }
4772
4773
3/4
✓ Branch 0 taken 280832 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 279296 times.
280832 if(Header && (Header->zelda_version < 0x193))
4774 {
4775
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4776 {
4777 return qe_invalid;
4778 }
4779 1536 }
4780
4781
2/2
✓ Branch 0 taken 201728 times.
✓ Branch 1 taken 79104 times.
280832 if ( s_version >= 11 )
4782 {
4783
2/4
✓ Branch 0 taken 201728 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 201728 times.
✗ Branch 3 not taken.
201728 if(!p_igetl(&tempDMap.minimap_2_tile,f))
4784 {
4785 return qe_invalid;
4786 }
4787 201728 }
4788 else
4789 {
4790
2/4
✓ Branch 0 taken 79104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 79104 times.
✗ Branch 3 not taken.
79104 if(!p_igetw(&tempDMap.minimap_2_tile,f))
4791 {
4792 return qe_invalid;
4793 }
4794 }
4795
2/4
✓ Branch 0 taken 280832 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 280832 times.
✗ Branch 3 not taken.
280832 if(!p_getc(&tempDMap.minimap_2_cset,f))
4796 {
4797 return qe_invalid;
4798 }
4799
4800
3/4
✓ Branch 0 taken 280832 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 279296 times.
280832 if(Header && (Header->zelda_version < 0x193))
4801 {
4802
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4803 {
4804 return qe_invalid;
4805 }
4806 1536 }
4807
4808
2/2
✓ Branch 0 taken 201728 times.
✓ Branch 1 taken 79104 times.
280832 if ( s_version >= 11 )
4809 {
4810
2/4
✓ Branch 0 taken 201728 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 201728 times.
✗ Branch 3 not taken.
201728 if(!p_igetl(&tempDMap.largemap_1_tile,f))
4811 {
4812 return qe_invalid;
4813 }
4814 201728 }
4815 else
4816 {
4817
2/4
✓ Branch 0 taken 79104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 79104 times.
✗ Branch 3 not taken.
79104 if(!p_igetw(&tempDMap.largemap_1_tile,f))
4818 {
4819 return qe_invalid;
4820 }
4821 }
4822
4823
2/4
✓ Branch 0 taken 280832 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 280832 times.
✗ Branch 3 not taken.
280832 if(!p_getc(&tempDMap.largemap_1_cset,f))
4824 {
4825 return qe_invalid;
4826 }
4827
4828
3/4
✓ Branch 0 taken 280832 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 279296 times.
280832 if(Header && (Header->zelda_version < 0x193))
4829 {
4830
4831
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4832 {
4833 return qe_invalid;
4834 }
4835 1536 }
4836
4837
2/2
✓ Branch 0 taken 201728 times.
✓ Branch 1 taken 79104 times.
280832 if ( s_version >= 11 )
4838 {
4839
2/4
✓ Branch 0 taken 201728 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 201728 times.
✗ Branch 3 not taken.
201728 if(!p_igetl(&tempDMap.largemap_2_tile,f))
4840 {
4841 return qe_invalid;
4842 }
4843 201728 }
4844 else
4845 {
4846
2/4
✓ Branch 0 taken 79104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 79104 times.
✗ Branch 3 not taken.
79104 if(!p_igetw(&tempDMap.largemap_2_tile,f))
4847 {
4848 return qe_invalid;
4849 }
4850 }
4851
2/4
✓ Branch 0 taken 280832 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 280832 times.
✗ Branch 3 not taken.
280832 if(!p_getc(&tempDMap.largemap_2_cset,f))
4852 {
4853 return qe_invalid;
4854 }
4855
4856
2/4
✓ Branch 0 taken 280832 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 280832 times.
✗ Branch 3 not taken.
280832 if(!p_getstr(tempDMap.tmusic,sizeof(DMaps[0].tmusic)-1,f))
4857 {
4858 return qe_invalid;
4859 }
4860 }
4861
4862
2/2
✓ Branch 0 taken 269312 times.
✓ Branch 1 taken 12096 times.
281408 if(s_version>1)
4863 {
4864
2/4
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 269312 times.
✗ Branch 3 not taken.
269312 if(!p_getc(&tempDMap.tmusictrack,f))
4865 {
4866 return qe_invalid;
4867 }
4868
4869
2/4
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 269312 times.
✗ Branch 3 not taken.
269312 if(!p_getc(&tempDMap.active_subscreen,f))
4870 {
4871 return qe_invalid;
4872 }
4873
4874
2/4
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 269312 times.
✗ Branch 3 not taken.
269312 if(!p_getc(&tempDMap.passive_subscreen,f))
4875 {
4876 return qe_invalid;
4877 }
4878 269312 }
4879
4880
2/2
✓ Branch 0 taken 269312 times.
✓ Branch 1 taken 12096 times.
281408 if(s_version>2)
4881 {
4882 byte di[32];
4883
4884
2/4
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 269312 times.
✗ Branch 3 not taken.
269312 if(!pfread(&di, 32, f)) return qe_invalid;
4885
4886
2/2
✓ Branch 0 taken 68943872 times.
✓ Branch 1 taken 269312 times.
69213184 for(int32_t j=0; j<MAXITEMS; j++)
4887 {
4888
2/2
✓ Branch 0 taken 3854 times.
✓ Branch 1 taken 68940018 times.
68943872 if(di[j/8] & (1 << (j%8))) tempDMap.disableditems[j]=1;
4889 68940018 else tempDMap.disableditems[j]=0;
4890 68943872 }
4891 269312 }
4892
4893
2/2
✓ Branch 0 taken 269312 times.
✓ Branch 1 taken 12096 times.
281408 if(s_version >= 6)
4894 {
4895
2/4
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 269312 times.
✗ Branch 3 not taken.
269312 if(!p_igetl(&tempDMap.flags,f))
4896 {
4897 return qe_invalid;
4898 }
4899 269312 }
4900
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12096 times.
12096 else if(s_version>3)
4901 {
4902 char temp;
4903
4904 if(!p_getc(&temp,f))
4905 {
4906 return qe_invalid;
4907 }
4908
4909 tempDMap.flags = temp;
4910 }
4911
3/8
✓ Branch 0 taken 6537 times.
✓ Branch 1 taken 5559 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6537 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
12096 else if(tempDMap.level==0 && ((Header->zelda_version < 0x211) || ((Header->zelda_version == 0x211) && (Header->build<18))))
4912 {
4913 6537 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4914 6537 }
4915 else
4916 5559 tempDMap.flags=0;
4917
4918
2/2
✓ Branch 0 taken 269312 times.
✓ Branch 1 taken 12096 times.
281408 if(s_version<7)
4919 {
4920
5/6
✓ Branch 0 taken 6537 times.
✓ Branch 1 taken 5559 times.
✓ Branch 2 taken 6537 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2216 times.
✓ Branch 5 taken 4321 times.
12096 if(tempDMap.level==0 && get_bit(deprecated_rules,14))
4921 4321 tempDMap.flags|= dmfVIEWMAP;
4922 12096 }
4923
4924
2/2
✓ Branch 0 taken 269312 times.
✓ Branch 1 taken 12096 times.
281408 if(s_version<8)
4925 {
4926
4/4
✓ Branch 0 taken 6537 times.
✓ Branch 1 taken 5559 times.
✓ Branch 2 taken 631 times.
✓ Branch 3 taken 5906 times.
12096 if(tempDMap.level==0 && (tempDMap.type&dmfTYPE)==dmDNGN)
4927 {
4928 5906 tempDMap.type &= ~dmDNGN;
4929 5906 tempDMap.type |= dmCAVE;
4930 5906 }
4931
2/2
✓ Branch 0 taken 4201 times.
✓ Branch 1 taken 1989 times.
6190 else if((tempDMap.type&dmfTYPE)==dmCAVE)
4932 {
4933 1989 tempDMap.flags |= dmfMINIMAPCOLORFIX;
4934 1989 }
4935 12096 }
4936
4937
7/8
✓ Branch 0 taken 281408 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2112 times.
✓ Branch 3 taken 279296 times.
✓ Branch 4 taken 1536 times.
✓ Branch 5 taken 576 times.
✓ Branch 6 taken 1536 times.
✓ Branch 7 taken 279296 times.
281408 if(Header && ((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>=41)))
4938 280832 && (Header->zelda_version < 0x193))
4939 {
4940
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4941 {
4942 return qe_invalid;
4943 }
4944 1536 }
4945
4946
2/2
✓ Branch 0 taken 79680 times.
✓ Branch 1 taken 201728 times.
281408 if(s_version >= 10)
4947 {
4948
2/4
✓ Branch 0 taken 201728 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 201728 times.
✗ Branch 3 not taken.
201728 if(!p_getc(&tempDMap.sideview,f))
4949 {
4950 return qe_invalid;
4951 }
4952 201728 }
4953
2/2
✓ Branch 0 taken 201728 times.
✓ Branch 1 taken 79680 times.
281408 if(s_version < 10) tempDMap.sideview = 0;
4954
4955 //Dmap Scripts
4956
2/2
✓ Branch 0 taken 201728 times.
✓ Branch 1 taken 79680 times.
281408 if(s_version >= 12)
4957 {
4958
2/4
✓ Branch 0 taken 201728 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 201728 times.
✗ Branch 3 not taken.
201728 if(!p_igetw(&tempDMap.script,f))
4959 {
4960 return qe_invalid;
4961 }
4962
2/2
✓ Branch 0 taken 1613824 times.
✓ Branch 1 taken 201728 times.
1815552 for ( int32_t q = 0; q < 8; q++ )
4963 {
4964
2/4
✓ Branch 0 taken 1613824 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1613824 times.
✗ Branch 3 not taken.
1613824 if(!p_igetl(&tempDMap.initD[q],f))
4965 {
4966 return qe_invalid;
4967 }
4968 1613824 }
4969 201728 }
4970
2/2
✓ Branch 0 taken 201728 times.
✓ Branch 1 taken 79680 times.
281408 if ( s_version < 12 )
4971 {
4972 79680 tempDMap.script = 0;
4973
2/2
✓ Branch 0 taken 637440 times.
✓ Branch 1 taken 79680 times.
717120 for ( int32_t q = 0; q < 8; q++ )
4974 {
4975 637440 tempDMap.initD[q] = 0;
4976 637440 }
4977 79680 }
4978
4979
2/2
✓ Branch 0 taken 79680 times.
✓ Branch 1 taken 201728 times.
281408 if(s_version >= 13)
4980 {
4981
2/2
✓ Branch 0 taken 1613824 times.
✓ Branch 1 taken 201728 times.
1815552 for ( int32_t q = 0; q < 8; q++ )
4982 {
4983
2/2
✓ Branch 0 taken 104898560 times.
✓ Branch 1 taken 1613824 times.
106512384 for ( int32_t w = 0; w < 65; w++ )
4984 {
4985
2/4
✓ Branch 0 taken 104898560 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104898560 times.
✗ Branch 3 not taken.
104898560 if(!p_getc(&tempDMap.initD_label[q][w],f))
4986 {
4987 return qe_invalid;
4988 }
4989 104898560 }
4990 1613824 }
4991 201728 }
4992
2/2
✓ Branch 0 taken 201728 times.
✓ Branch 1 taken 79680 times.
281408 if ( s_version < 13 )
4993 {
4994 79680 tempDMap.script = 0;
4995
2/2
✓ Branch 0 taken 637440 times.
✓ Branch 1 taken 79680 times.
717120 for ( int32_t q = 0; q < 8; q++ )
4996 {
4997
2/2
✓ Branch 0 taken 41433600 times.
✓ Branch 1 taken 637440 times.
42071040 for ( int32_t w = 0; w < 65; w++ )
4998 41433600 tempDMap.initD_label[q][w] = 0;
4999 637440 }
5000 79680 }
5001
2/2
✓ Branch 0 taken 201728 times.
✓ Branch 1 taken 79680 times.
281408 if(s_version >= 14)
5002 {
5003
2/4
✓ Branch 0 taken 201728 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 201728 times.
✗ Branch 3 not taken.
201728 if(!p_igetw(&tempDMap.active_sub_script,f))
5004 {
5005 return qe_invalid;
5006 }
5007
2/4
✓ Branch 0 taken 201728 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 201728 times.
✗ Branch 3 not taken.
201728 if(!p_igetw(&tempDMap.passive_sub_script,f))
5008 {
5009 return qe_invalid;
5010 }
5011
2/2
✓ Branch 0 taken 1613824 times.
✓ Branch 1 taken 201728 times.
1815552 for ( int32_t q = 0; q < 8; ++q )
5012 {
5013
2/4
✓ Branch 0 taken 1613824 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1613824 times.
✗ Branch 3 not taken.
1613824 if(!p_igetl(&tempDMap.sub_initD[q],f))
5014 {
5015 return qe_invalid;
5016 }
5017 1613824 }
5018
2/2
✓ Branch 0 taken 1613824 times.
✓ Branch 1 taken 201728 times.
1815552 for(int32_t q = 0; q < 8; ++q)
5019 {
5020
2/2
✓ Branch 0 taken 104898560 times.
✓ Branch 1 taken 1613824 times.
106512384 for ( int32_t w = 0; w < 65; ++w )
5021 {
5022
2/4
✓ Branch 0 taken 104898560 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104898560 times.
✗ Branch 3 not taken.
104898560 if(!p_getc(&tempDMap.sub_initD_label[q][w],f))
5023 {
5024 return qe_invalid;
5025 }
5026 104898560 }
5027 1613824 }
5028 201728 }
5029 else
5030 {
5031 79680 tempDMap.active_sub_script = 0;
5032 79680 tempDMap.passive_sub_script = 0;
5033
2/2
✓ Branch 0 taken 637440 times.
✓ Branch 1 taken 79680 times.
717120 for(int32_t q = 0; q < 8; ++q)
5034 {
5035 637440 tempDMap.sub_initD[q] = 0;
5036
2/2
✓ Branch 0 taken 41433600 times.
✓ Branch 1 taken 637440 times.
42071040 for(int32_t w = 0; w < 65; ++w)
5037 41433600 tempDMap.sub_initD_label[q][w] = 0;
5038 637440 }
5039 }
5040
2/2
✓ Branch 0 taken 201728 times.
✓ Branch 1 taken 79680 times.
281408 if(s_version >= 15)
5041 {
5042
2/4
✓ Branch 0 taken 201728 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 201728 times.
✗ Branch 3 not taken.
201728 if(!p_igetw(&tempDMap.onmap_script,f))
5043 {
5044 return qe_invalid;
5045 }
5046
2/2
✓ Branch 0 taken 1613824 times.
✓ Branch 1 taken 201728 times.
1815552 for ( int32_t q = 0; q < 8; ++q )
5047 {
5048
2/4
✓ Branch 0 taken 1613824 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1613824 times.
✗ Branch 3 not taken.
1613824 if(!p_igetl(&tempDMap.onmap_initD[q],f))
5049 {
5050 return qe_invalid;
5051 }
5052 1613824 }
5053
2/2
✓ Branch 0 taken 1613824 times.
✓ Branch 1 taken 201728 times.
1815552 for(int32_t q = 0; q < 8; ++q)
5054 {
5055
2/2
✓ Branch 0 taken 104898560 times.
✓ Branch 1 taken 1613824 times.
106512384 for ( int32_t w = 0; w < 65; ++w )
5056 {
5057
2/4
✓ Branch 0 taken 104898560 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104898560 times.
✗ Branch 3 not taken.
104898560 if(!p_getc(&tempDMap.onmap_initD_label[q][w],f))
5058 {
5059 return qe_invalid;
5060 }
5061 104898560 }
5062 1613824 }
5063 201728 }
5064 else
5065 {
5066 79680 tempDMap.onmap_script = 0;
5067
2/2
✓ Branch 0 taken 637440 times.
✓ Branch 1 taken 79680 times.
717120 for(int32_t q = 0; q < 8; ++q)
5068 {
5069 637440 tempDMap.onmap_initD[q] = 0;
5070
2/2
✓ Branch 0 taken 41433600 times.
✓ Branch 1 taken 637440 times.
42071040 for(int32_t w = 0; w < 65; ++w)
5071 {
5072 41433600 tempDMap.onmap_initD_label[q][w] = 0;
5073 41433600 }
5074 637440 }
5075 }
5076
2/2
✓ Branch 0 taken 201728 times.
✓ Branch 1 taken 79680 times.
281408 if(s_version >= 16)
5077 {
5078
2/4
✓ Branch 0 taken 201728 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 201728 times.
✗ Branch 3 not taken.
201728 if(!p_igetw(&tempDMap.mirrorDMap,f))
5079 {
5080 return qe_invalid;
5081 }
5082 201728 }
5083 else
5084 {
5085 79680 tempDMap.mirrorDMap = -1;
5086 }
5087
5088
2/2
✓ Branch 0 taken 88896 times.
✓ Branch 1 taken 192512 times.
281408 if (s_version >= 17)
5089 {
5090 // Reserved for z3.
5091 192512 }
5092
5093 // Enhanced music loop points
5094
2/2
✓ Branch 0 taken 192512 times.
✓ Branch 1 taken 88896 times.
281408 if (s_version >= 18)
5095 {
5096
2/4
✓ Branch 0 taken 192512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 192512 times.
✗ Branch 3 not taken.
192512 if (!p_igetl(&tempDMap.tmusic_loop_start, f))
5097 {
5098 return qe_invalid;
5099 }
5100
2/4
✓ Branch 0 taken 192512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 192512 times.
✗ Branch 3 not taken.
192512 if (!p_igetl(&tempDMap.tmusic_loop_end, f))
5101 {
5102 return qe_invalid;
5103 }
5104
2/4
✓ Branch 0 taken 192512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 192512 times.
✗ Branch 3 not taken.
192512 if (!p_igetl(&tempDMap.tmusic_xfade_in, f))
5105 {
5106 return qe_invalid;
5107 }
5108
2/4
✓ Branch 0 taken 192512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 192512 times.
✗ Branch 3 not taken.
192512 if (!p_igetl(&tempDMap.tmusic_xfade_out, f))
5109 {
5110 return qe_invalid;
5111 }
5112 192512 }
5113 else
5114 {
5115 88896 tempDMap.tmusic_loop_start = 0;
5116 88896 tempDMap.tmusic_loop_end = 0;
5117 88896 tempDMap.tmusic_xfade_in = 0;
5118 88896 tempDMap.tmusic_xfade_out = 0;
5119 }
5120
5121
2/2
✓ Branch 0 taken 192512 times.
✓ Branch 1 taken 88896 times.
281408 if(s_version >= 19)
5122
2/4
✓ Branch 0 taken 192512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 192512 times.
✗ Branch 3 not taken.
192512 if(!p_getc(&tempDMap.overlay_subscreen, f))
5123 return qe_invalid;
5124
5125
2/2
✓ Branch 0 taken 192512 times.
✓ Branch 1 taken 88896 times.
281408 if (s_version >= 20)
5126 {
5127
2/4
✓ Branch 0 taken 192512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 192512 times.
✗ Branch 3 not taken.
192512 if (!p_igetl(&tempDMap.intro_string_id, f))
5128 return qe_invalid;
5129 192512 }
5130 else
5131 88896 tempDMap.intro_string_id = 0;
5132
5133 // Reserved for z3.
5134
2/2
✓ Branch 0 taken 88896 times.
✓ Branch 1 taken 192512 times.
281408 if(s_version >= 21)
5135 {
5136
2/2
✓ Branch 0 taken 1540096 times.
✓ Branch 1 taken 192512 times.
1732608 for(int32_t j=0; j<8; j++)
5137 {
5138
2/2
✓ Branch 0 taken 12320768 times.
✓ Branch 1 taken 1540096 times.
13860864 for(int32_t k=0; k<8; k++)
5139 {
5140 char c;
5141
2/4
✓ Branch 0 taken 12320768 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12320768 times.
✗ Branch 3 not taken.
12320768 if(!p_getc(&c,f))
5142 {
5143 return qe_invalid;
5144 }
5145 12320768 }
5146 1540096 }
5147 192512 }
5148
5149
2/2
✓ Branch 0 taken 281152 times.
✓ Branch 1 taken 256 times.
281408 if (!should_skip)
5150 {
5151
1/2
✓ Branch 0 taken 281152 times.
✗ Branch 1 not taken.
281152 if(loading_tileset_flags & TILESET_CLEARMAPS)
5152 tempDMap.map = 0;
5153
1/2
✓ Branch 0 taken 281152 times.
✗ Branch 1 not taken.
281152 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
5154 {
5155 tempDMap.script = 0;
5156 for(int q = 0; q < 8; ++q)
5157 tempDMap.initD[q] = 0;
5158 }
5159
1/2
✓ Branch 0 taken 281152 times.
✗ Branch 1 not taken.
281152 DMaps[i] = tempDMap;
5160 281152 }
5161 281408 }
5162
5163 589 return 0;
5164 6733 }
5165
5166 526 int32_t readmisccolors(PACKFILE *f, zquestheader *Header, miscQdata *Misc)
5167 {
5168 //these are here to bypass compiler warnings about unused arguments
5169 526 Header=Header;
5170
5171 miscQdata temp_misc;
5172 526 word s_version=0, s_cversion=0;
5173 526 int32_t tempsize=0;
5174 word dummyw;
5175
5176 526 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5177
5178 //section version info
5179
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 526 times.
526 if(!p_igetw(&s_version,f))
5180 {
5181 return qe_invalid;
5182 }
5183
5184 526 FFCore.quest_format[vColours] = s_version;
5185
5186 526 al_trace("Misc Colours section version: %d\n", s_version);
5187
5188 //al_trace("Misc. colors version %d\n", s_version);
5189
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 if(!p_igetw(&s_cversion,f))
5190 {
5191 return qe_invalid;
5192 }
5193
5194
5195 //section size
5196
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 if(!p_igetl(&tempsize,f))
5197 {
5198 return qe_invalid;
5199 }
5200
5201 //finally... section data
5202 526 readsize=0;
5203
5204
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 if(!p_getc(&temp_misc.colors.text,f))
5205 {
5206 return qe_invalid;
5207 }
5208
5209
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 if(!p_getc(&temp_misc.colors.caption,f))
5210 {
5211 return qe_invalid;
5212 }
5213
5214
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 if(!p_getc(&temp_misc.colors.overw_bg,f))
5215 {
5216 return qe_invalid;
5217 }
5218
5219
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 if(!p_getc(&temp_misc.colors.dngn_bg,f))
5220 {
5221 return qe_invalid;
5222 }
5223
5224
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 if(!p_getc(&temp_misc.colors.dngn_fg,f))
5225 {
5226 return qe_invalid;
5227 }
5228
5229
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 if(!p_getc(&temp_misc.colors.cave_fg,f))
5230 {
5231 return qe_invalid;
5232 }
5233
5234
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 if(!p_getc(&temp_misc.colors.bs_dk,f))
5235 {
5236 return qe_invalid;
5237 }
5238
5239
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 if(!p_getc(&temp_misc.colors.bs_goal,f))
5240 {
5241 return qe_invalid;
5242 }
5243
5244
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 if(!p_getc(&temp_misc.colors.compass_lt,f))
5245 {
5246 return qe_invalid;
5247 }
5248
5249
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 if(!p_getc(&temp_misc.colors.compass_dk,f))
5250 {
5251 return qe_invalid;
5252 }
5253
5254
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 if(!p_getc(&temp_misc.colors.subscr_bg,f))
5255 {
5256 return qe_invalid;
5257 }
5258
5259
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 if(!p_getc(&temp_misc.colors.triframe_color,f))
5260 {
5261 return qe_invalid;
5262 }
5263
5264
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 if(!p_getc(&temp_misc.colors.hero_dot,f))
5265 {
5266 return qe_invalid;
5267 }
5268
5269
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 if(!p_getc(&temp_misc.colors.bmap_bg,f))
5270 {
5271 return qe_invalid;
5272 }
5273
5274
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 if(!p_getc(&temp_misc.colors.bmap_fg,f))
5275 {
5276 return qe_invalid;
5277 }
5278
5279
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 if(!p_getc(&temp_misc.colors.triforce_cset,f))
5280 {
5281 return qe_invalid;
5282 }
5283
5284
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 if(!p_getc(&temp_misc.colors.triframe_cset,f))
5285 {
5286 return qe_invalid;
5287 }
5288
5289
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 if(!p_getc(&temp_misc.colors.overworld_map_cset,f))
5290 {
5291 return qe_invalid;
5292 }
5293
5294
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f))
5295 {
5296 return qe_invalid;
5297 }
5298
5299
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 if(!p_getc(&temp_misc.colors.blueframe_cset,f))
5300 {
5301 return qe_invalid;
5302 }
5303
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 132 times.
526 if(s_version < 4)
5304 {
5305
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(!p_igetw(&dummyw,f))
5306 return qe_invalid;
5307 132 temp_misc.colors.triforce_tile = dummyw;
5308
5309
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(!p_igetw(&dummyw,f))
5310 return qe_invalid;
5311 132 temp_misc.colors.triframe_tile = dummyw;
5312
5313
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(!p_igetw(&dummyw,f))
5314 return qe_invalid;
5315 132 temp_misc.colors.overworld_map_tile = dummyw;
5316
5317
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(!p_igetw(&dummyw,f))
5318 return qe_invalid;
5319 132 temp_misc.colors.dungeon_map_tile = dummyw;
5320
5321
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(!p_igetw(&dummyw,f))
5322 return qe_invalid;
5323 132 temp_misc.colors.blueframe_tile = dummyw;
5324
5325
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(!p_igetw(&dummyw,f))
5326 return qe_invalid;
5327 132 temp_misc.colors.HCpieces_tile = dummyw;
5328 132 }
5329
5330
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 if(!p_getc(&temp_misc.colors.HCpieces_cset,f))
5331 {
5332 return qe_invalid;
5333 }
5334
5335
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 if(!p_getc(&temp_misc.colors.subscr_shadow,f))
5336 {
5337 return qe_invalid;
5338 }
5339
5340
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 526 times.
526 if(s_version < 2)
5341 {
5342 temp_misc.colors.msgtext = 0x01;
5343 }
5344 else
5345 {
5346
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 if(!p_getc(&temp_misc.colors.msgtext, f))
5347 {
5348 return qe_invalid;
5349 }
5350 }
5351
5352
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 394 times.
526 if ( s_version >= 3 ) //expanded tile pages to 825
5353 {
5354
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if(!p_igetl(&temp_misc.colors.triforce_tile,f))
5355 {
5356 return qe_invalid;
5357 }
5358
5359
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if(!p_igetl(&temp_misc.colors.triframe_tile,f))
5360 {
5361 return qe_invalid;
5362 }
5363
5364
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if(!p_igetl(&temp_misc.colors.overworld_map_tile,f))
5365 {
5366 return qe_invalid;
5367 }
5368
5369
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if(!p_igetl(&temp_misc.colors.dungeon_map_tile,f))
5370 {
5371 return qe_invalid;
5372 }
5373
5374
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if(!p_igetl(&temp_misc.colors.blueframe_tile,f))
5375 {
5376 return qe_invalid;
5377 }
5378
5379
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 394 times.
394 if(!p_igetl(&temp_misc.colors.HCpieces_tile,f))
5380 {
5381 return qe_invalid;
5382 }
5383 394 }
5384
5385 526 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5386
5387 526 return 0;
5388 526 }
5389
5390 526 int32_t readgameicons(PACKFILE *f, zquestheader *, miscQdata *Misc)
5391 {
5392 miscQdata temp_misc;
5393 526 word s_version=0, s_cversion=0;
5394 byte icons;
5395 526 int32_t tempsize=0;
5396
5397 526 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5398
5399 //section version info
5400
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 526 times.
526 if(!p_igetw(&s_version,f))
5401 {
5402 return qe_invalid;
5403 }
5404
5405 526 FFCore.quest_format[vIcons] = s_version;
5406
5407 //al_trace("Game icons version %d\n", s_version);
5408
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 if(!p_igetw(&s_cversion,f))
5409 {
5410 return qe_invalid;
5411 }
5412
5413
5414 //section size
5415
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 if(!p_igetl(&tempsize,f))
5416 {
5417 return qe_invalid;
5418 }
5419
5420 //finally... section data
5421 526 readsize=0;
5422
5423 526 icons=4;
5424
5425
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 132 times.
526 if ( s_version >= 10 )
5426 {
5427
2/2
✓ Branch 0 taken 1576 times.
✓ Branch 1 taken 394 times.
1970 for(int32_t i=0; i<icons; i++)
5428 {
5429
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1576 times.
1576 if(!p_igetl(&temp_misc.icons[i],f))
5430 {
5431 return qe_invalid;
5432 }
5433 1576 }
5434 394 }
5435 else
5436 {
5437
2/2
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 132 times.
660 for(int32_t i=0; i<icons; i++)
5438 {
5439
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 528 times.
528 if(!p_igetw(&temp_misc.icons[i],f))
5440 {
5441 return qe_invalid;
5442 }
5443 528 }
5444 }
5445
5446 526 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5447
5448 526 return 0;
5449 526 }
5450
5451 589 int32_t readmisc(PACKFILE *f, zquestheader *Header, miscQdata *Misc)
5452 {
5453
2/2
✓ Branch 0 taken 565 times.
✓ Branch 1 taken 24 times.
589 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_misc);
5454
5455 589 word maxinfos=256;
5456 589 word maxshops=256;
5457 589 word shops=16, infos=16, warprings=8, palcycles=256, windwarps=9, triforces=8, icons=4;
5458 589 word ponds=16, pondsize=72, expansionsize=98*2;
5459 byte tempbyte, padding;
5460 miscQdata temp_misc;
5461 589 word s_version=0, s_cversion=0;
5462 word swaptmp;
5463 589 int32_t tempsize=0;
5464
5465 589 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5466
5467
2/2
✓ Branch 0 taken 150784 times.
✓ Branch 1 taken 589 times.
151373 for(int32_t i=0; i<maxshops; ++i)
5468 {
5469 150784 memset(&temp_misc.shop, 0, sizeof(shoptype)*256);
5470 150784 }
5471
5472
2/2
✓ Branch 0 taken 150784 times.
✓ Branch 1 taken 589 times.
151373 for(int32_t i=0; i<maxinfos; ++i)
5473 {
5474 150784 memset(&temp_misc.info, 0, sizeof(infotype)*256);
5475 150784 }
5476
5477
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 565 times.
589 if(Header->zelda_version > 0x192)
5478 {
5479 //section version info
5480
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 if(!p_igetw(&s_version,f))
5481 {
5482 return qe_invalid;
5483 }
5484
5485 565 FFCore.quest_format[vMisc] = s_version;
5486
5487 //al_trace("Misc. data version %d\n", s_version);
5488
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 if(!p_igetw(&s_cversion,f))
5489 {
5490 return qe_invalid;
5491 }
5492
5493
5494 //section size
5495
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 if(!p_igetl(&tempsize,f))
5496 {
5497 return qe_invalid;
5498 }
5499 565 }
5500
5501 //finally... section data
5502 589 readsize=0;
5503
5504 //shops
5505
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 565 times.
589 if(Header->zelda_version > 0x192)
5506 {
5507
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 if(!p_igetw(&shops,f))
5508 {
5509 return qe_invalid;
5510 }
5511 565 }
5512
5513
2/4
✓ Branch 0 taken 589 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 589 times.
589 if (!(shops >= 0 && shops <= NUM_SHOPS))
5514 {
5515 return qe_invalid;
5516 }
5517
5518
2/2
✓ Branch 0 taken 8524 times.
✓ Branch 1 taken 589 times.
9113 for(int32_t i=0; i<shops; i++)
5519 {
5520
2/2
✓ Branch 0 taken 905 times.
✓ Branch 1 taken 7619 times.
8524 if(s_version > 6)
5521 {
5522
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7619 times.
7619 if(!p_getstr(temp_misc.shop[i].name,sizeof(temp_misc.shop[i].name)-1,f))
5523 {
5524 return qe_invalid;
5525 }
5526 7619 }
5527
5528
2/2
✓ Branch 0 taken 25572 times.
✓ Branch 1 taken 8524 times.
34096 for(int32_t j=0; j<3; j++)
5529 {
5530
1/2
✓ Branch 0 taken 25572 times.
✗ Branch 1 not taken.
25572 if(!p_getc(&temp_misc.shop[i].item[j],f))
5531 {
5532 return qe_invalid;
5533 }
5534
5535
2/2
✓ Branch 0 taken 22857 times.
✓ Branch 1 taken 2715 times.
25572 if(s_version < 4)
5536 {
5537 2715 temp_misc.shop[i].hasitem[j] = (temp_misc.shop[i].item[j] == 0) ? 0 : 1;
5538 2715 }
5539 25572 }
5540
5541
2/2
✓ Branch 0 taken 8140 times.
✓ Branch 1 taken 384 times.
8524 if(Header->zelda_version < 0x193)
5542 {
5543
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(!p_getc(&tempbyte,f))
5544 {
5545 return qe_invalid;
5546 }
5547 384 }
5548
5549
2/2
✓ Branch 0 taken 25572 times.
✓ Branch 1 taken 8524 times.
34096 for(int32_t j=0; j<3; j++)
5550 {
5551
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25572 times.
25572 if(!p_igetw(&temp_misc.shop[i].price[j],f))
5552 {
5553 return qe_invalid;
5554 }
5555 25572 }
5556
5557
2/2
✓ Branch 0 taken 905 times.
✓ Branch 1 taken 7619 times.
8524 if(s_version > 3)
5558 {
5559
2/2
✓ Branch 0 taken 22857 times.
✓ Branch 1 taken 7619 times.
30476 for(int32_t j=0; j<3; j++)
5560 {
5561
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22857 times.
22857 if(!p_getc(&temp_misc.shop[i].hasitem[j],f))
5562 return qe_invalid;
5563 22857 }
5564 7619 }
5565
5566 /*
5567 if(s_version < 8)
5568 {
5569 for(int32_t j=0; j<3; j++)
5570 {
5571 (&temp_misc.shop[i].str[j])=0; //initialise.
5572 }
5573 }
5574 */
5575 8524 }
5576
5577 //filter all the 0 items to the end (yeah, bubble sort; sue me)
5578
2/2
✓ Branch 0 taken 150784 times.
✓ Branch 1 taken 589 times.
151373 for(int32_t i=0; i<maxshops; ++i)
5579 {
5580
2/2
✓ Branch 0 taken 301568 times.
✓ Branch 1 taken 150784 times.
452352 for(int32_t j=0; j<3-1; j++)
5581 {
5582
2/2
✓ Branch 0 taken 301568 times.
✓ Branch 1 taken 440188 times.
741756 for(int32_t k=0; k<2-j; k++)
5583 {
5584 440188 if(temp_misc.shop[i].hasitem[k]==0)
5585 {
5586 440188 swaptmp = temp_misc.shop[i].item[k];
5587 440188 temp_misc.shop[i].item[k] = temp_misc.shop[i].item[k+1];
5588 440188 temp_misc.shop[i].item[k+1] = swaptmp;
5589 440188 swaptmp = temp_misc.shop[i].price[k];
5590 440188 temp_misc.shop[i].price[k] = temp_misc.shop[i].price[k+1];
5591 440188 temp_misc.shop[i].price[k+1] = swaptmp;
5592 440188 swaptmp = temp_misc.shop[i].hasitem[k];
5593 440188 temp_misc.shop[i].hasitem[k] = temp_misc.shop[i].hasitem[k+1];
5594 440188 temp_misc.shop[i].hasitem[k+1] = swaptmp;
5595 440188 }
5596 440188 }
5597 301568 }
5598 150784 }
5599
5600 //infos
5601
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 565 times.
589 if(Header->zelda_version > 0x192)
5602 {
5603
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 if(!p_igetw(&infos,f))
5604 {
5605 return qe_invalid;
5606 }
5607 565 }
5608
5609
2/4
✓ Branch 0 taken 589 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 589 times.
589 if (!(infos >= 0 && infos <= NUM_INFOS))
5610 {
5611 return qe_invalid;
5612 }
5613
5614
5615
2/2
✓ Branch 0 taken 8402 times.
✓ Branch 1 taken 589 times.
8991 for(int32_t i=0; i<infos; i++)
5616 {
5617
2/2
✓ Branch 0 taken 630 times.
✓ Branch 1 taken 7772 times.
8402 if(s_version > 6)
5618 {
5619
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7772 times.
7772 if(!p_getstr(temp_misc.info[i].name,sizeof(temp_misc.info[i].name)-1,f))
5620 {
5621 return qe_invalid;
5622 }
5623 7772 }
5624
5625
2/2
✓ Branch 0 taken 25206 times.
✓ Branch 1 taken 8402 times.
33608 for(int32_t j=0; j<3; j++)
5626 {
5627
3/4
✓ Branch 0 taken 24342 times.
✓ Branch 1 taken 864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 288 times.
25494 if((Header->zelda_version < 0x192)||
5628
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 24054 times.
24342 ((Header->zelda_version == 0x192)&&(Header->build<146)))
5629 {
5630
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 864 times.
864 if(!p_getc(&tempbyte,f))
5631 {
5632 return qe_invalid;
5633 }
5634
5635 864 temp_misc.info[i].str[j]=tempbyte;
5636 864 }
5637 else
5638 {
5639
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24342 times.
24342 if(!p_igetw(&temp_misc.info[i].str[j],f))
5640 {
5641 return qe_invalid;
5642 }
5643 }
5644 25206 }
5645
5646
2/2
✓ Branch 0 taken 8018 times.
✓ Branch 1 taken 384 times.
8402 if(Header->zelda_version < 0x193)
5647 {
5648
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&tempbyte,f))
5649 {
5650 return qe_invalid;
5651 }
5652 384 }
5653
5654
3/4
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 8306 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 96 times.
8402 if((Header->zelda_version == 0x192)&&(Header->build>145))
5655 {
5656
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&padding,f))
5657 {
5658 return qe_invalid;
5659 }
5660 96 }
5661
5662
2/2
✓ Branch 0 taken 25206 times.
✓ Branch 1 taken 8402 times.
33608 for(int32_t j=0; j<3; j++)
5663 {
5664
1/2
✓ Branch 0 taken 25206 times.
✗ Branch 1 not taken.
25206 if(!p_igetw(&temp_misc.info[i].price[j],f))
5665 {
5666 return qe_invalid;
5667 }
5668 25206 }
5669 8402 }
5670
5671 //filter all the 0 strings to the end (yeah, bubble sort; sue me)
5672
2/2
✓ Branch 0 taken 150784 times.
✓ Branch 1 taken 589 times.
151373 for(int32_t i=0; i<maxinfos; ++i)
5673 {
5674
2/2
✓ Branch 0 taken 301568 times.
✓ Branch 1 taken 150784 times.
452352 for(int32_t j=0; j<3-1; j++)
5675 {
5676
2/2
✓ Branch 0 taken 452352 times.
✓ Branch 1 taken 301568 times.
753920 for(int32_t k=0; k<2-j; k++)
5677 {
5678
2/2
✓ Branch 0 taken 9427 times.
✓ Branch 1 taken 442925 times.
452352 if(temp_misc.info[i].str[k]==0)
5679 {
5680 442925 swaptmp = temp_misc.info[i].str[k];
5681 442925 temp_misc.info[i].str[k] = temp_misc.info[i].str[k+1];
5682 442925 temp_misc.info[i].str[k+1] = swaptmp;
5683 442925 swaptmp = temp_misc.info[i].price[k];
5684 442925 temp_misc.info[i].price[k] = temp_misc.info[i].price[k+1];
5685 442925 temp_misc.info[i].price[k+1] = swaptmp;
5686 442925 }
5687 452352 }
5688 301568 }
5689 150784 }
5690
5691
5692 //warp rings
5693
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 526 times.
589 if(s_version > 5)
5694 526 warprings++;
5695
5696
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 565 times.
589 if(Header->zelda_version > 0x192)
5697 {
5698
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 if(!p_igetw(&warprings,f))
5699 {
5700 return qe_invalid;
5701 }
5702
5703
3/4
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 486 times.
✓ Branch 3 taken 79 times.
565 if (!(warprings >= 0 && warprings <= NUM_WARP_RINGS))
5704 {
5705 // return qe_invalid;
5706 // Note: we can't actually fail here because for some reason, some quest files have more than the max
5707 // number of possible warp rings. Some examples of this are: demosp253.qst, yuurand.qst
5708 // So instead below we disable `keepdata` when reading the bad warp ring data, so no memory is corrupted.
5709 79 }
5710 565 }
5711
5712
2/2
✓ Branch 0 taken 5656 times.
✓ Branch 1 taken 589 times.
6245 for(int32_t i=0; i<warprings; i++)
5713 {
5714 // See above comment on the `warprings` range check.
5715 5656 bool keepdata = i < NUM_WARP_RINGS;
5716
5717
2/2
✓ Branch 0 taken 50104 times.
✓ Branch 1 taken 5656 times.
55760 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5718 {
5719
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 43704 times.
50104 if(s_version <= 3)
5720 {
5721
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_getc(&tempbyte,f))
5722 {
5723 return qe_invalid;
5724 }
5725
5726
2/2
✓ Branch 0 taken 2072 times.
✓ Branch 1 taken 4328 times.
6400 if (keepdata)
5727 4328 temp_misc.warp[i].dmap[j]=(word)tempbyte;
5728 6400 }
5729 else
5730 {
5731 word tempword;
5732
1/2
✓ Branch 0 taken 43704 times.
✗ Branch 1 not taken.
43704 if(!p_igetw(&tempword,f))
5733 {
5734 return qe_invalid;
5735 }
5736
5737
2/2
✓ Branch 0 taken 1098 times.
✓ Branch 1 taken 42606 times.
43704 if (keepdata)
5738 42606 temp_misc.warp[i].dmap[j] = tempword;
5739 }
5740 50104 }
5741
5742
2/2
✓ Branch 0 taken 50104 times.
✓ Branch 1 taken 5656 times.
55760 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5743 {
5744
1/2
✓ Branch 0 taken 50104 times.
✗ Branch 1 not taken.
50104 if(!p_getc(&tempbyte,f))
5745 {
5746 return qe_invalid;
5747 }
5748
2/2
✓ Branch 0 taken 3170 times.
✓ Branch 1 taken 46934 times.
50104 if (keepdata)
5749 46934 temp_misc.warp[i].scr[j] = tempbyte;
5750 50104 }
5751
5752
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5656 times.
5656 if(!p_getc(&tempbyte,f))
5753 {
5754 return qe_invalid;
5755 }
5756
2/2
✓ Branch 0 taken 381 times.
✓ Branch 1 taken 5275 times.
5656 if (keepdata)
5757 5275 temp_misc.warp[i].size = tempbyte;
5758
5759
2/2
✓ Branch 0 taken 5464 times.
✓ Branch 1 taken 192 times.
5656 if(Header->zelda_version < 0x193)
5760 {
5761
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_getc(&tempbyte,f))
5762 {
5763 return qe_invalid;
5764 }
5765 192 }
5766 5656 }
5767
5768 //palette cycles
5769
2/2
✓ Branch 0 taken 565 times.
✓ Branch 1 taken 24 times.
589 if(Header->zelda_version < 0x193) //in 1.93+, palette cycling is saved with the palettes
5770 {
5771
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 24 times.
6168 for(int32_t i=0; i<256; i++)
5772 {
5773
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 6144 times.
24576 for(int32_t j=0; j<3; j++)
5774 {
5775 18432 temp_misc.cycles[i][j].first=0;
5776 18432 temp_misc.cycles[i][j].count=0;
5777 18432 temp_misc.cycles[i][j].speed=0;
5778 18432 }
5779 6144 }
5780
5781
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
30 if((Header->zelda_version < 0x192)||
5782
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((Header->zelda_version == 0x192)&&(Header->build<73)))
5783 {
5784 18 palcycles=16;
5785 18 }
5786
5787
2/2
✓ Branch 0 taken 1824 times.
✓ Branch 1 taken 24 times.
1848 for(int32_t i=0; i<palcycles; i++)
5788 {
5789
2/2
✓ Branch 0 taken 5472 times.
✓ Branch 1 taken 1824 times.
7296 for(int32_t j=0; j<3; j++)
5790 {
5791
1/2
✓ Branch 0 taken 5472 times.
✗ Branch 1 not taken.
5472 if(!p_getc(&temp_misc.cycles[i][j].first,f))
5792 {
5793 return qe_invalid;
5794 }
5795
5796
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5472 times.
5472 if(!p_getc(&temp_misc.cycles[i][j].count,f))
5797 {
5798 return qe_invalid;
5799 }
5800
5801
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5472 times.
5472 if(!p_getc(&temp_misc.cycles[i][j].speed,f))
5802 {
5803 return qe_invalid;
5804 }
5805 5472 }
5806 1824 }
5807 24 }
5808
5809 //Wind warps are now just another warp ring.
5810
2/2
✓ Branch 0 taken 526 times.
✓ Branch 1 taken 63 times.
589 if(s_version <= 5)
5811 {
5812
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 39 times.
63 if(Header->zelda_version > 0x192)
5813 {
5814
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 if(!p_igetw(&windwarps,f))
5815 {
5816 return qe_invalid;
5817 }
5818 39 }
5819
5820
2/4
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 63 times.
63 if (!(windwarps >= 0 && windwarps <= NUM_WARP_RINGS))
5821 {
5822 return qe_invalid;
5823 }
5824
5825
2/2
✓ Branch 0 taken 513 times.
✓ Branch 1 taken 63 times.
576 for(int32_t i=0; i<windwarps; i++)
5826 {
5827
1/2
✓ Branch 0 taken 513 times.
✗ Branch 1 not taken.
513 if(s_version <= 3)
5828 {
5829
1/2
✓ Branch 0 taken 513 times.
✗ Branch 1 not taken.
513 if(!p_getc(&tempbyte,f))
5830 {
5831 return qe_invalid;
5832 }
5833
5834 513 temp_misc.warp[8].dmap[i]=tempbyte;
5835 513 }
5836 else
5837 {
5838 if(!p_igetw(&temp_misc.warp[8].dmap[i],f))
5839 {
5840 return qe_invalid;
5841 }
5842 }
5843
5844
1/2
✓ Branch 0 taken 513 times.
✗ Branch 1 not taken.
513 if(!p_getc(&temp_misc.warp[8].scr[i],f))
5845 {
5846 return qe_invalid;
5847 }
5848
5849 513 temp_misc.warp[8].size = 9;
5850
5851
1/2
✓ Branch 0 taken 513 times.
✗ Branch 1 not taken.
513 if(s_version == 5)
5852 {
5853 if(!p_getc(&tempbyte,f))
5854 {
5855 return qe_invalid;
5856 }
5857 }
5858 513 }
5859 63 }
5860
5861
5862 //triforce pieces
5863
2/2
✓ Branch 0 taken 4712 times.
✓ Branch 1 taken 589 times.
5301 for(int32_t i=0; i<triforces; i++)
5864 {
5865
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4712 times.
4712 if(!p_getc(&temp_misc.triforce[i],f))
5866 {
5867 return qe_invalid;
5868 }
5869 4712 }
5870
5871 //misc color data
5872
2/2
✓ Branch 0 taken 526 times.
✓ Branch 1 taken 63 times.
589 if(s_version<3)
5873 {
5874
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 if(!p_getc(&temp_misc.colors.text,f))
5875 {
5876 return qe_invalid;
5877 }
5878
5879
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 if(!p_getc(&temp_misc.colors.caption,f))
5880 {
5881 return qe_invalid;
5882 }
5883
5884
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 if(!p_getc(&temp_misc.colors.overw_bg,f))
5885 {
5886 return qe_invalid;
5887 }
5888
5889
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 if(!p_getc(&temp_misc.colors.dngn_bg,f))
5890 {
5891 return qe_invalid;
5892 }
5893
5894
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 if(!p_getc(&temp_misc.colors.dngn_fg,f))
5895 {
5896 return qe_invalid;
5897 }
5898
5899
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 if(!p_getc(&temp_misc.colors.cave_fg,f))
5900 {
5901 return qe_invalid;
5902 }
5903
5904
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 if(!p_getc(&temp_misc.colors.bs_dk,f))
5905 {
5906 return qe_invalid;
5907 }
5908
5909
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 if(!p_getc(&temp_misc.colors.bs_goal,f))
5910 {
5911 return qe_invalid;
5912 }
5913
5914
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 if(!p_getc(&temp_misc.colors.compass_lt,f))
5915 {
5916 return qe_invalid;
5917 }
5918
5919
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 if(!p_getc(&temp_misc.colors.compass_dk,f))
5920 {
5921 return qe_invalid;
5922 }
5923
5924
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 if(!p_getc(&temp_misc.colors.subscr_bg,f))
5925 {
5926 return qe_invalid;
5927 }
5928
5929
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 if(!p_getc(&temp_misc.colors.triframe_color,f))
5930 {
5931 return qe_invalid;
5932 }
5933
5934
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 if(!p_getc(&temp_misc.colors.hero_dot,f))
5935 {
5936 return qe_invalid;
5937 }
5938
5939
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 if(!p_getc(&temp_misc.colors.bmap_bg,f))
5940 {
5941 return qe_invalid;
5942 }
5943
5944
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 if(!p_getc(&temp_misc.colors.bmap_fg,f))
5945 {
5946 return qe_invalid;
5947 }
5948
5949
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 if(!p_getc(&temp_misc.colors.triforce_cset,f))
5950 {
5951 return qe_invalid;
5952 }
5953
5954
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 if(!p_getc(&temp_misc.colors.triframe_cset,f))
5955 {
5956 return qe_invalid;
5957 }
5958
5959
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 if(!p_getc(&temp_misc.colors.overworld_map_cset,f))
5960 {
5961 return qe_invalid;
5962 }
5963
5964
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f))
5965 {
5966 return qe_invalid;
5967 }
5968
5969
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 if(!p_getc(&temp_misc.colors.blueframe_cset,f))
5970 {
5971 return qe_invalid;
5972 }
5973
5974
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 if(!p_igetw(&temp_misc.colors.triforce_tile,f))
5975 {
5976 return qe_invalid;
5977 }
5978
5979
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 if(!p_igetw(&temp_misc.colors.triframe_tile,f))
5980 {
5981 return qe_invalid;
5982 }
5983
5984
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 if(!p_igetw(&temp_misc.colors.overworld_map_tile,f))
5985 {
5986 return qe_invalid;
5987 }
5988
5989
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 if(!p_igetw(&temp_misc.colors.dungeon_map_tile,f))
5990 {
5991 return qe_invalid;
5992 }
5993
5994
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 if(!p_igetw(&temp_misc.colors.blueframe_tile,f))
5995 {
5996 return qe_invalid;
5997 }
5998
5999
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 if(!p_igetw(&temp_misc.colors.HCpieces_tile,f))
6000 {
6001 return qe_invalid;
6002 }
6003
6004
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 if(!p_getc(&temp_misc.colors.HCpieces_cset,f))
6005 {
6006 return qe_invalid;
6007 }
6008
6009 63 temp_misc.colors.msgtext = 0x01;
6010
6011
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 24 times.
63 if(Header->zelda_version < 0x193)
6012 {
6013
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 24 times.
192 for(int32_t i=0; i<7; i++)
6014 {
6015
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 if(!p_getc(&tempbyte,f))
6016 {
6017 return qe_invalid;
6018 }
6019 168 }
6020 24 }
6021
6022
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 57 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
63 if((Header->zelda_version == 0x192)&&(Header->build>145))
6023 {
6024
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 6 times.
1542 for(int32_t i=0; i<256; i++)
6025 {
6026
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1536 times.
1536 if(!p_getc(&tempbyte,f))
6027 {
6028 return qe_invalid;
6029 }
6030 1536 }
6031 6 }
6032
6033
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 if(s_version>1)
6034 {
6035 if(!p_getc(&temp_misc.colors.subscr_shadow,f))
6036 {
6037 return qe_invalid;
6038 }
6039 }
6040
6041 //save game icons
6042
3/4
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
69 if((Header->zelda_version < 0x192)||
6043
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 39 times.
45 ((Header->zelda_version == 0x192)&&(Header->build<73)))
6044 {
6045 18 icons=3;
6046 18 }
6047
6048
2/2
✓ Branch 0 taken 234 times.
✓ Branch 1 taken 63 times.
297 for(int32_t i=0; i<icons; i++)
6049 {
6050
1/2
✓ Branch 0 taken 234 times.
✗ Branch 1 not taken.
234 if(!p_igetw(&temp_misc.icons[i],f))
6051 {
6052 return qe_invalid;
6053 }
6054 234 }
6055 63 }
6056
6057
3/4
✓ Branch 0 taken 571 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
595 if((Header->zelda_version < 0x192)||
6058
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 565 times.
571 ((Header->zelda_version == 0x192)&&(Header->build<30)))
6059 {
6060 18 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6061
6062 18 return 0;
6063 }
6064
6065 //pond information
6066
2/2
✓ Branch 0 taken 565 times.
✓ Branch 1 taken 6 times.
571 if(Header->zelda_version < 0x193)
6067 {
6068
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if((Header->zelda_version == 0x192)&&(Header->build<146))
6069 {
6070 pondsize=25;
6071 }
6072
6073
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 6 times.
102 for(int32_t i=0; i<ponds; i++)
6074 {
6075
2/2
✓ Branch 0 taken 6912 times.
✓ Branch 1 taken 96 times.
7008 for(int32_t j=0; j<pondsize; j++)
6076 {
6077
1/2
✓ Branch 0 taken 6912 times.
✗ Branch 1 not taken.
6912 if(!p_getc(&tempbyte,f))
6078 {
6079 return qe_invalid;
6080
6081 }
6082 6912 }
6083 96 }
6084 6 }
6085
6086 //end string
6087
2/4
✓ Branch 0 taken 571 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
577 if((Header->zelda_version < 0x192)||
6088
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 565 times.
571 ((Header->zelda_version == 0x192)&&(Header->build<146)))
6089 {
6090 if(!p_getc(&tempbyte,f))
6091 {
6092 return qe_invalid;
6093 }
6094
6095 temp_misc.endstring=tempbyte;
6096
6097 if(!p_getc(&tempbyte,f))
6098 {
6099 return qe_invalid;
6100 }
6101 }
6102 else
6103 {
6104
1/2
✓ Branch 0 taken 571 times.
✗ Branch 1 not taken.
571 if(!p_igetw(&temp_misc.endstring,f))
6105 {
6106 return qe_invalid;
6107 }
6108 }
6109
6110 //expansion
6111
2/2
✓ Branch 0 taken 565 times.
✓ Branch 1 taken 6 times.
571 if(Header->zelda_version < 0x193)
6112 {
6113
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if((Header->zelda_version == 0x192)&&(Header->build<73))
6114 {
6115 expansionsize=99*2;
6116 }
6117
6118
2/2
✓ Branch 0 taken 1176 times.
✓ Branch 1 taken 6 times.
1182 for(int32_t i=0; i<expansionsize; i++)
6119 {
6120
1/2
✓ Branch 0 taken 1176 times.
✗ Branch 1 not taken.
1176 if(!p_getc(&tempbyte,f))
6121 {
6122 return qe_invalid;
6123 }
6124 1176 }
6125 6 }
6126 //shops v8
6127
6128
6129
2/2
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 394 times.
571 if(s_version >= 8)
6130 {
6131
2/2
✓ Branch 0 taken 6160 times.
✓ Branch 1 taken 394 times.
6554 for(int32_t i=0; i<shops; i++)
6132 {
6133
2/2
✓ Branch 0 taken 18480 times.
✓ Branch 1 taken 6160 times.
24640 for(int32_t j=0; j<3; j++)
6134 {
6135
1/2
✓ Branch 0 taken 18480 times.
✗ Branch 1 not taken.
18480 if(!p_igetw(&temp_misc.shop[i].str[j],f))
6136 return qe_invalid;
6137 18480 }
6138 6160 }
6139 394 }
6140
6141 571 memset(&temp_misc.questmisc, 0, sizeof(int32_t)*32);
6142 571 memset(&temp_misc.questmisc_strings, 0, sizeof(char)*4096);
6143 571 memset(&temp_misc.zscript_last_compiled_version, 0, sizeof(int32_t));
6144
6145 //v9 includes quest misc[32]
6146
2/2
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 394 times.
571 if(s_version >= 9)
6147 {
6148
2/2
✓ Branch 0 taken 12608 times.
✓ Branch 1 taken 394 times.
13002 for ( int32_t q = 0; q < 32; q++ )
6149 {
6150
1/2
✓ Branch 0 taken 12608 times.
✗ Branch 1 not taken.
12608 if(!p_igetl(&temp_misc.questmisc[q],f))
6151 return qe_invalid;
6152 12608 }
6153
2/2
✓ Branch 0 taken 12608 times.
✓ Branch 1 taken 394 times.
13002 for ( int32_t q = 0; q < 32; q++ )
6154 {
6155
2/2
✓ Branch 0 taken 1613824 times.
✓ Branch 1 taken 12608 times.
1626432 for ( int32_t j = 0; j < 128; j++ )
6156
1/2
✓ Branch 0 taken 1613824 times.
✗ Branch 1 not taken.
1613824 if(!p_getc(&temp_misc.questmisc_strings[q][j],f))
6157 return qe_invalid;
6158 12608 }
6159 394 }
6160
6161
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 177 times.
571 if(s_version >= 11 )
6162 {
6163
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if(!p_igetl(&temp_misc.zscript_last_compiled_version,f))
6164 return qe_invalid;
6165 394 }
6166
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 177 times.
177 else if(s_version < 11 )
6167 {
6168 177 temp_misc.zscript_last_compiled_version = -1;
6169 177 }
6170
6171 571 FFCore.quest_format[vLastCompile] = temp_misc.zscript_last_compiled_version;
6172
6173
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 177 times.
571 if(s_version >= 12)
6174 {
6175 byte spr;
6176
2/2
✓ Branch 0 taken 100864 times.
✓ Branch 1 taken 394 times.
101258 for(int32_t q = 0; q < sprMAX; ++q)
6177 {
6178
1/2
✓ Branch 0 taken 100864 times.
✗ Branch 1 not taken.
100864 if(!p_getc(&spr,f))
6179 return qe_invalid;
6180 100864 temp_misc.sprites[q] = spr;
6181 100864 }
6182 394 }
6183 else
6184 {
6185 177 memset(&(temp_misc.sprites), 0, sizeof(temp_misc.sprites));
6186 //temp_misc.sprites[sprFALL] = ;
6187 }
6188
6189
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 177 times.
571 if(s_version >= 13)
6190 {
6191
2/2
✓ Branch 0 taken 25216 times.
✓ Branch 1 taken 394 times.
25610 for(size_t q = 0; q < 64; ++q)
6192 {
6193 25216 bottletype* bt = &(temp_misc.bottle_types[q]);
6194
1/2
✓ Branch 0 taken 25216 times.
✗ Branch 1 not taken.
25216 if (!p_getstr(bt->name, sizeof(bt->name)-1, f))
6195 return qe_invalid;
6196
2/2
✓ Branch 0 taken 75648 times.
✓ Branch 1 taken 25216 times.
100864 for(size_t j = 0; j < 3; ++j)
6197 {
6198
1/2
✓ Branch 0 taken 75648 times.
✗ Branch 1 not taken.
75648 if (!p_getc(&(bt->counter[j]), f))
6199 return qe_invalid;
6200
1/2
✓ Branch 0 taken 75648 times.
✗ Branch 1 not taken.
75648 if (!p_igetw(&(bt->amount[j]), f))
6201 return qe_invalid;
6202 75648 }
6203
1/2
✓ Branch 0 taken 25216 times.
✗ Branch 1 not taken.
25216 if (!p_getc(&(bt->flags), f))
6204 return qe_invalid;
6205
1/2
✓ Branch 0 taken 25216 times.
✗ Branch 1 not taken.
25216 if (!p_getc(&(bt->next_type), f))
6206 return qe_invalid;
6207 25216 }
6208
2/2
✓ Branch 0 taken 100864 times.
✓ Branch 1 taken 394 times.
101258 for(size_t q = 0; q < 256; ++q)
6209 {
6210 100864 bottleshoptype* bst = &(temp_misc.bottle_shop_types[q]);
6211
1/2
✓ Branch 0 taken 100864 times.
✗ Branch 1 not taken.
100864 if (!pfread(bst->name, sizeof(bst->name)-1, f))
6212 return qe_invalid;
6213
2/2
✓ Branch 0 taken 302592 times.
✓ Branch 1 taken 100864 times.
403456 for(size_t j = 0; j < 3; ++j)
6214 {
6215
1/2
✓ Branch 0 taken 302592 times.
✗ Branch 1 not taken.
302592 if (!p_getc(&(bst->fill[j]), f))
6216 return qe_invalid;
6217
1/2
✓ Branch 0 taken 302592 times.
✗ Branch 1 not taken.
302592 if (!p_igetw(&(bst->comb[j]), f))
6218 return qe_invalid;
6219
1/2
✓ Branch 0 taken 302592 times.
✗ Branch 1 not taken.
302592 if (!p_getc(&(bst->cset[j]), f))
6220 return qe_invalid;
6221
1/2
✓ Branch 0 taken 302592 times.
✗ Branch 1 not taken.
302592 if (!p_igetw(&(bst->price[j]), f))
6222 return qe_invalid;
6223
1/2
✓ Branch 0 taken 302592 times.
✗ Branch 1 not taken.
302592 if (!p_igetw(&(bst->str[j]), f))
6224 return qe_invalid;
6225 302592 }
6226 100864 }
6227 394 }
6228 else
6229 {
6230
2/2
✓ Branch 0 taken 11328 times.
✓ Branch 1 taken 177 times.
11505 for(size_t q = 0; q < 64; ++q)
6231 11328 temp_misc.bottle_types[q].clear();
6232
2/2
✓ Branch 0 taken 45312 times.
✓ Branch 1 taken 177 times.
45489 for(size_t q = 0; q < 256; ++q)
6233 45312 temp_misc.bottle_shop_types[q].clear();
6234 }
6235
6236
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 177 times.
571 if(s_version >= 14)
6237 {
6238 byte msfx;
6239
2/2
✓ Branch 0 taken 100864 times.
✓ Branch 1 taken 394 times.
101258 for(int32_t q = 0; q < sfxMAX; ++q)
6240 {
6241
1/2
✓ Branch 0 taken 100864 times.
✗ Branch 1 not taken.
100864 if(!p_getc(&msfx,f))
6242 return qe_invalid;
6243 100864 temp_misc.miscsfx[q] = msfx;
6244 100864 }
6245 394 }
6246 else
6247 {
6248 177 memset(&(temp_misc.miscsfx), 0, sizeof(temp_misc.miscsfx));
6249 177 temp_misc.miscsfx[sfxBUSHGRASS] = WAV_ZN1GRASSCUT;
6250 177 temp_misc.miscsfx[sfxLOWHEART] = WAV_ER;
6251 }
6252
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 177 times.
571 if(s_version < 15)
6253 {
6254 177 temp_misc.miscsfx[sfxHURTPLAYER] = WAV_OUCH;
6255 177 temp_misc.miscsfx[sfxHAMMERPOUND] = WAV_ZN1HAMMERPOST;
6256 177 temp_misc.miscsfx[sfxSUBSCR_ITEM_ASSIGN] = WAV_PLACE;
6257 177 temp_misc.miscsfx[sfxSUBSCR_CURSOR_MOVE] = WAV_CHIME;
6258 177 temp_misc.miscsfx[sfxREFILL] = WAV_MSG;
6259 177 temp_misc.miscsfx[sfxDRAIN] = WAV_MSG;
6260 177 }
6261
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 195 times.
571 if(s_version < 16)
6262 {
6263 195 temp_misc.miscsfx[sfxTAP] = WAV_ZN1TAP;
6264 195 temp_misc.miscsfx[sfxTAP_HOLLOW] = WAV_ZN1TAP2;
6265 195 }
6266
6267
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 570 times.
571 if (!should_skip)
6268 570 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6269
6270 571 return 0;
6271 589 }
6272
6273 extern char *item_string[MAXITEMS];
6274 extern const char *old_item_string[iLast];
6275 extern char *weapon_string[MAXWPNS];
6276 extern const char *old_weapon_string[wLast];
6277
6278 589 int32_t readitems(PACKFILE *f, word version, word build)
6279 {
6280
2/2
✓ Branch 0 taken 565 times.
✓ Branch 1 taken 24 times.
589 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_items);
6281
6282 byte padding;
6283 int32_t dummy;
6284 589 word items_to_read=MAXITEMS;
6285 itemdata tempitem;
6286 589 word s_version=0, s_cversion=0;
6287 word dummy_word;
6288
6289
2/2
✓ Branch 0 taken 583 times.
✓ Branch 1 taken 6 times.
589 if(version < 0x186)
6290 {
6291 6 items_to_read=64;
6292 6 }
6293
6294
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 565 times.
589 if(version > 0x192)
6295 {
6296 565 items_to_read=0;
6297
6298 //section version info
6299
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 if(!p_igetw(&s_version,f))
6300 {
6301 return qe_invalid;
6302 }
6303
6304 565 FFCore.quest_format[vItems] = s_version;
6305
6306 //al_trace("Items version %d\n", s_version);
6307
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 if(!p_igetw(&s_cversion,f))
6308 {
6309 return qe_invalid;
6310 }
6311
6312 //section size
6313
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 if(!p_igetl(&dummy,f))
6314 {
6315 return qe_invalid;
6316 }
6317
6318 //finally... section data
6319
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 if(!p_igetw(&items_to_read,f))
6320 {
6321 return qe_invalid;
6322 }
6323
6324
2/4
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 565 times.
565 if (!(items_to_read >= 0 && items_to_read <= MAXITEMS))
6325 {
6326 return qe_invalid;
6327 }
6328 565 }
6329
6330
2/2
✓ Branch 0 taken 526 times.
✓ Branch 1 taken 63 times.
589 if(s_version>1)
6331 {
6332
2/2
✓ Branch 0 taken 134656 times.
✓ Branch 1 taken 526 times.
135182 for(int32_t i=0; i<items_to_read; i++)
6333 {
6334 char tempname[64];
6335
6336
1/2
✓ Branch 0 taken 134656 times.
✗ Branch 1 not taken.
134656 if(!pfread(tempname, 64, f))
6337 {
6338 return qe_invalid;
6339 }
6340
6341 134656 item_string[i][0] = '\0';
6342 134656 strncat(item_string[i], tempname, 64 - 1);
6343 134656 }
6344 526 }
6345
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 62 times.
63 else if (!should_skip)
6346 {
6347
2/2
✓ Branch 0 taken 15872 times.
✓ Branch 1 taken 62 times.
15934 for(int32_t i=0; i<MAXITEMS; i++)
6348 {
6349 15872 reset_itemname(i);
6350 15872 }
6351 62 }
6352
6353
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 588 times.
589 if (!should_skip)
6354
2/2
✓ Branch 0 taken 150528 times.
✓ Branch 1 taken 588 times.
151116 for(int32_t i=0; i<MAXITEMS; i++)
6355 {
6356 150528 itemdata& id = itemsbuf[i];
6357 150528 memset(&id, 0, sizeof(itemdata));
6358 150528 id.count=-1;
6359 150528 id.playsound=WAV_SCALE;
6360 150528 reset_itembuf(&id,i);
6361 151116 }
6362
6363
2/2
✓ Branch 0 taken 142378 times.
✓ Branch 1 taken 589 times.
142967 for(int32_t i=0; i<items_to_read; i++)
6364 {
6365 142378 memset(&tempitem, 0, sizeof(itemdata));
6366 142378 reset_itembuf(&tempitem,i);
6367
6368
6369
2/2
✓ Branch 0 taken 100864 times.
✓ Branch 1 taken 41514 times.
142378 if ( s_version > 35 ) //expanded tiles
6370 {
6371
1/2
✓ Branch 0 taken 100864 times.
✗ Branch 1 not taken.
100864 if(!p_igetl(&tempitem.tile,f))
6372 {
6373 return qe_invalid;
6374 }
6375 100864 }
6376 else
6377 {
6378
1/2
✓ Branch 0 taken 41514 times.
✗ Branch 1 not taken.
41514 if(!p_igetw(&tempitem.tile,f))
6379 {
6380 return qe_invalid;
6381 }
6382 }
6383
6384
1/2
✓ Branch 0 taken 142378 times.
✗ Branch 1 not taken.
142378 if(!p_getc(&tempitem.misc_flags,f))
6385 {
6386 return qe_invalid;
6387 }
6388
6389
1/2
✓ Branch 0 taken 142378 times.
✗ Branch 1 not taken.
142378 if(!p_getc(&tempitem.csets,f))
6390 {
6391 return qe_invalid;
6392 }
6393
6394
1/2
✓ Branch 0 taken 142378 times.
✗ Branch 1 not taken.
142378 if(!p_getc(&tempitem.frames,f))
6395 {
6396 return qe_invalid;
6397 }
6398
6399
1/2
✓ Branch 0 taken 142378 times.
✗ Branch 1 not taken.
142378 if(!p_getc(&tempitem.speed,f))
6400 {
6401 return qe_invalid;
6402 }
6403
6404
1/2
✓ Branch 0 taken 142378 times.
✗ Branch 1 not taken.
142378 if(!p_getc(&tempitem.delay,f))
6405 {
6406 return qe_invalid;
6407 }
6408
6409
2/2
✓ Branch 0 taken 137386 times.
✓ Branch 1 taken 4992 times.
142378 if(version < 0x193)
6410 {
6411
1/2
✓ Branch 0 taken 4992 times.
✗ Branch 1 not taken.
4992 if(!p_getc(&padding,f))
6412 {
6413 return qe_invalid;
6414 }
6415
6416
4/6
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 3456 times.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1536 times.
✗ Branch 5 not taken.
4992 if((version < 0x192)||((version == 0x192)&&(build<186)))
6417 {
6418
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 4736 times.
4992 if (should_skip)
6419 256 continue;
6420
6421
3/3
✓ Branch 0 taken 4690 times.
✓ Branch 1 taken 23 times.
✓ Branch 2 taken 23 times.
4736 switch(i)
6422 {
6423 case iShield:
6424 23 tempitem.ltm=get_qr(qr_BSZELDA)?-12:10;
6425 23 break;
6426
6427 case iMShield:
6428 23 tempitem.ltm=get_qr(qr_BSZELDA)?-6:-10;
6429 23 break;
6430
6431 default:
6432 4690 tempitem.ltm=0;
6433 4690 break;
6434 }
6435
6436 4736 tempitem.count=-1;
6437 4736 tempitem.flags=tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=
6438 4736 tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
6439 4736 tempitem.family=0xFF;
6440 4736 tempitem.playsound=WAV_SCALE;
6441 4736 reset_itembuf(&tempitem,i);
6442
6443 4736 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
6444
6445 4736 continue;
6446 }
6447 }
6448
6449
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137386 times.
137386 if(!p_igetl(&tempitem.ltm,f))
6450 {
6451 return qe_invalid;
6452 }
6453
6454
1/2
✓ Branch 0 taken 137386 times.
✗ Branch 1 not taken.
137386 if(version < 0x193)
6455 {
6456 for(int32_t q=0; q<12; q++)
6457 {
6458 if(!p_getc(&padding,f))
6459 {
6460 return qe_invalid;
6461 }
6462 }
6463 }
6464
6465
2/2
✓ Branch 0 taken 134656 times.
✓ Branch 1 taken 2730 times.
137386 if(s_version>1)
6466 {
6467
2/2
✓ Branch 0 taken 100864 times.
✓ Branch 1 taken 33792 times.
134656 if ( s_version >= 31 )
6468 {
6469
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100864 times.
100864 if(!p_igetl(&tempitem.family,f))
6470 {
6471 return qe_invalid;
6472 }
6473 100864 }
6474 else
6475 {
6476
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33792 times.
33792 if(!p_getc(&tempitem.family,f))
6477 {
6478 return qe_invalid;
6479 }
6480 }
6481
1/2
✓ Branch 0 taken 134656 times.
✗ Branch 1 not taken.
134656 if(s_version < 16)
6482 if(tempitem.family == 0xFF)
6483 tempitem.family = itype_misc;
6484
6485
1/2
✓ Branch 0 taken 134656 times.
✗ Branch 1 not taken.
134656 if(!p_getc(&tempitem.fam_type,f))
6486 {
6487 return qe_invalid;
6488 }
6489
6490
1/2
✓ Branch 0 taken 134656 times.
✗ Branch 1 not taken.
134656 if(s_version>5)
6491 {
6492
2/2
✓ Branch 0 taken 100864 times.
✓ Branch 1 taken 33792 times.
134656 if(s_version>=31)
6493 {
6494
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100864 times.
100864 if(!p_igetl(&tempitem.power,f))
6495 {
6496 return qe_invalid;
6497 }
6498 100864 }
6499 else
6500 {
6501
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33792 times.
33792 if(!p_getc(&tempitem.power,f))
6502 {
6503 return qe_invalid;
6504 }
6505 }
6506
6507 //converted flags from 16b to 32b -Z
6508
2/2
✓ Branch 0 taken 33792 times.
✓ Branch 1 taken 100864 times.
134656 if ( s_version < 41 )
6509 {
6510
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33792 times.
33792 if(!p_igetw(&tempitem.flags,f))
6511 {
6512 return qe_invalid;
6513 }
6514 33792 }
6515 else
6516 {
6517
1/2
✓ Branch 0 taken 100864 times.
✗ Branch 1 not taken.
100864 if(!p_igetl(&tempitem.flags,f))
6518 {
6519 return qe_invalid;
6520 }
6521 }
6522 134656 }
6523 else
6524 {
6525 //tempitem.power = tempitem.fam_type;
6526 char tempchar;
6527
6528 if(!p_getc(&tempchar,f))
6529 {
6530 return qe_invalid;
6531 }
6532
6533 tempitem.flags |= (tempchar ? ITEM_GAMEDATA : 0);
6534 }
6535
6536
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 134656 times.
134656 if(!p_igetw(&tempitem.script,f))
6537 {
6538 return qe_invalid;
6539 }
6540
6541
1/2
✓ Branch 0 taken 134656 times.
✗ Branch 1 not taken.
134656 if(s_version<=3)
6542 {
6543 if(tempitem.script > NUMSCRIPTITEM)
6544 {
6545 tempitem.script = 0;
6546 }
6547 }
6548
6549
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 134656 times.
134656 if(!p_getc(&tempitem.count,f))
6550 {
6551 return qe_invalid;
6552 }
6553
6554
1/2
✓ Branch 0 taken 134656 times.
✗ Branch 1 not taken.
134656 if(!p_igetw(&tempitem.amount,f))
6555 {
6556 return qe_invalid;
6557 }
6558
6559
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 134656 times.
134656 if(!p_igetw(&tempitem.collect_script,f))
6560 {
6561 return qe_invalid;
6562 }
6563
6564
1/2
✓ Branch 0 taken 134656 times.
✗ Branch 1 not taken.
134656 if(s_version<=3)
6565 {
6566 if(tempitem.collect_script > NUMSCRIPTITEM)
6567 {
6568 tempitem.collect_script = 0;
6569 }
6570 }
6571
6572
1/2
✓ Branch 0 taken 134656 times.
✗ Branch 1 not taken.
134656 if(!p_igetw(&tempitem.setmax,f))
6573 {
6574 return qe_invalid;
6575 }
6576
6577
1/2
✓ Branch 0 taken 134656 times.
✗ Branch 1 not taken.
134656 if(!p_igetw(&tempitem.max,f))
6578 {
6579 return qe_invalid;
6580 }
6581
6582
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 134656 times.
134656 if(!p_getc(&tempitem.playsound,f))
6583 {
6584 return qe_invalid;
6585 }
6586
6587
2/2
✓ Branch 0 taken 1077248 times.
✓ Branch 1 taken 134656 times.
1211904 for(int32_t j=0; j<8; j++)
6588 {
6589
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1077248 times.
1077248 if(!p_igetl(&tempitem.initiald[j],f))
6590 {
6591 return qe_invalid;
6592 }
6593 1077248 }
6594
6595
2/2
✓ Branch 0 taken 269312 times.
✓ Branch 1 taken 134656 times.
403968 for(int32_t j=0; j<2; j++)
6596 {
6597
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(!p_getc(&tempitem.initiala[j],f))
6598 {
6599 return qe_invalid;
6600 }
6601 269312 }
6602
6603
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 134656 times.
134656 if(s_version>4)
6604 {
6605
1/2
✓ Branch 0 taken 134656 times.
✗ Branch 1 not taken.
134656 if(s_version>5)
6606 {
6607
1/2
✓ Branch 0 taken 134656 times.
✗ Branch 1 not taken.
134656 if(!p_getc(&tempitem.wpn,f))
6608 {
6609 return qe_invalid;
6610 }
6611
6612
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 134656 times.
134656 if(!p_getc(&tempitem.wpn2,f))
6613 {
6614 return qe_invalid;
6615 }
6616
6617
1/2
✓ Branch 0 taken 134656 times.
✗ Branch 1 not taken.
134656 if(!p_getc(&tempitem.wpn3,f))
6618 {
6619 return qe_invalid;
6620 }
6621
6622
1/2
✓ Branch 0 taken 134656 times.
✗ Branch 1 not taken.
134656 if(!p_getc(&tempitem.wpn4,f))
6623 {
6624 return qe_invalid;
6625 }
6626
6627
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 134656 times.
134656 if(s_version>=15)
6628 {
6629
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 134656 times.
134656 if(!p_getc(&tempitem.wpn5,f))
6630 {
6631 return qe_invalid;
6632 }
6633
6634
1/2
✓ Branch 0 taken 134656 times.
✗ Branch 1 not taken.
134656 if(!p_getc(&tempitem.wpn6,f))
6635 {
6636 return qe_invalid;
6637 }
6638
6639
1/2
✓ Branch 0 taken 134656 times.
✗ Branch 1 not taken.
134656 if(!p_getc(&tempitem.wpn7,f))
6640 {
6641 return qe_invalid;
6642 }
6643
6644
1/2
✓ Branch 0 taken 134656 times.
✗ Branch 1 not taken.
134656 if(!p_getc(&tempitem.wpn8,f))
6645 {
6646 return qe_invalid;
6647 }
6648
6649
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 134656 times.
134656 if(!p_getc(&tempitem.wpn9,f))
6650 {
6651 return qe_invalid;
6652 }
6653
6654
1/2
✓ Branch 0 taken 134656 times.
✗ Branch 1 not taken.
134656 if(!p_getc(&tempitem.wpn10,f))
6655 {
6656 return qe_invalid;
6657 }
6658 134656 }
6659
6660
1/2
✓ Branch 0 taken 134656 times.
✗ Branch 1 not taken.
134656 if(!p_getc(&tempitem.pickup_hearts,f))
6661 {
6662 return qe_invalid;
6663 }
6664
6665
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 134656 times.
134656 if(s_version<15)
6666 {
6667 if(!p_igetw(&dummy_word,f))
6668 {
6669 return qe_invalid;
6670 }
6671
6672 tempitem.misc1=dummy_word;
6673
6674 if(!p_igetw(&dummy_word,f))
6675 {
6676 return qe_invalid;
6677 }
6678
6679 tempitem.misc2=dummy_word;
6680 }
6681 else
6682 {
6683
1/2
✓ Branch 0 taken 134656 times.
✗ Branch 1 not taken.
134656 if(!p_igetl(&tempitem.misc1,f))
6684 {
6685 return qe_invalid;
6686 }
6687
6688
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 134656 times.
134656 if(!p_igetl(&tempitem.misc2,f))
6689 {
6690 return qe_invalid;
6691 }
6692
6693 // Version 24: shICE -> shSCRIPT; previously, all shields could block script weapons
6694
1/2
✓ Branch 0 taken 134656 times.
✗ Branch 1 not taken.
134656 if(s_version<24)
6695 {
6696 if(tempitem.family==itype_shield)
6697 {
6698 tempitem.misc1|=shSCRIPT;
6699 }
6700 }
6701 }
6702
6703
2/2
✓ Branch 0 taken 33792 times.
✓ Branch 1 taken 100864 times.
134656 if(s_version < 53)
6704 {
6705 byte tempbyte;
6706
1/2
✓ Branch 0 taken 33792 times.
✗ Branch 1 not taken.
33792 if(!p_getc(&tempbyte,f))
6707 {
6708 return qe_invalid;
6709 }
6710 33792 tempitem.cost_amount[0] = tempbyte;
6711 33792 }
6712 else
6713 {
6714
2/2
✓ Branch 0 taken 201728 times.
✓ Branch 1 taken 100864 times.
302592 for(auto q = 0; q < 2; ++q)
6715 {
6716
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 201728 times.
201728 if(!p_igetw(&tempitem.cost_amount[q],f))
6717 {
6718 return qe_invalid;
6719 }
6720 201728 }
6721 }
6722 134656 }
6723 else
6724 {
6725 char tempchar;
6726
6727 if(!p_getc(&tempchar,f))
6728 {
6729 return qe_invalid;
6730 }
6731
6732 tempitem.flags |= (tempchar ? ITEM_EDIBLE : 0);
6733 }
6734
6735 // June 2007: more misc. attributes
6736
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 134656 times.
134656 if(s_version>=12)
6737 {
6738
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 134656 times.
134656 if(s_version<15)
6739 {
6740 if(!p_igetw(&dummy_word,f))
6741 {
6742 return qe_invalid;
6743 }
6744
6745 tempitem.misc3=dummy_word;
6746
6747 if(!p_igetw(&dummy_word,f))
6748 {
6749 return qe_invalid;
6750 }
6751
6752 tempitem.misc4=dummy_word;
6753 }
6754 else
6755 {
6756
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 134656 times.
134656 if(!p_igetl(&tempitem.misc3,f))
6757 {
6758 return qe_invalid;
6759 }
6760
6761
1/2
✓ Branch 0 taken 134656 times.
✗ Branch 1 not taken.
134656 if(!p_igetl(&tempitem.misc4,f))
6762 {
6763 return qe_invalid;
6764 }
6765
6766
1/2
✓ Branch 0 taken 134656 times.
✗ Branch 1 not taken.
134656 if(!p_igetl(&tempitem.misc5,f))
6767 {
6768 return qe_invalid;
6769 }
6770
6771
1/2
✓ Branch 0 taken 134656 times.
✗ Branch 1 not taken.
134656 if(!p_igetl(&tempitem.misc6,f))
6772 {
6773 return qe_invalid;
6774 }
6775
6776
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 134656 times.
134656 if(!p_igetl(&tempitem.misc7,f))
6777 {
6778 return qe_invalid;
6779 }
6780
6781
1/2
✓ Branch 0 taken 134656 times.
✗ Branch 1 not taken.
134656 if(!p_igetl(&tempitem.misc8,f))
6782 {
6783 return qe_invalid;
6784 }
6785
6786
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 134656 times.
134656 if(!p_igetl(&tempitem.misc9,f))
6787 {
6788 return qe_invalid;
6789 }
6790
6791
1/2
✓ Branch 0 taken 134656 times.
✗ Branch 1 not taken.
134656 if(!p_igetl(&tempitem.misc10,f))
6792 {
6793 return qe_invalid;
6794 }
6795 }
6796
6797
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 134656 times.
134656 if(!p_getc(&tempitem.usesound,f))
6798 {
6799 return qe_invalid;
6800 }
6801
6802
2/2
✓ Branch 0 taken 100864 times.
✓ Branch 1 taken 33792 times.
134656 if(s_version >= 49)
6803 {
6804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100864 times.
100864 if(!p_getc(&tempitem.usesound2,f))
6805 {
6806 return qe_invalid;
6807 }
6808 100864 }
6809 33792 else tempitem.usesound2 = 0;
6810
6811
3/4
✓ Branch 0 taken 33792 times.
✓ Branch 1 taken 100864 times.
✓ Branch 2 taken 33792 times.
✗ Branch 3 not taken.
134656 if(s_version < 50 && tempitem.family == itype_mirror)
6812 {
6813 //Split continue/dmap warp effect/sfx, port for old
6814 tempitem.misc2 = tempitem.misc1;
6815 tempitem.usesound2 = tempitem.usesound;
6816 }
6817 134656 }
6818 134656 }
6819
6820
2/2
✓ Branch 0 taken 33792 times.
✓ Branch 1 taken 100864 times.
134656 if ( s_version >= 26 ) //! New itemdata vars for weapon editor. -Z
6821 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6822
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100864 times.
100864 if(!p_getc(&tempitem.useweapon,f))
6823 {
6824 return qe_invalid;
6825 }
6826
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100864 times.
100864 if(!p_getc(&tempitem.usedefence,f))
6827 {
6828 return qe_invalid;
6829 }
6830
1/2
✓ Branch 0 taken 100864 times.
✗ Branch 1 not taken.
100864 if(!p_igetl(&tempitem.weaprange,f))
6831 {
6832 return qe_invalid;
6833 }
6834
1/2
✓ Branch 0 taken 100864 times.
✗ Branch 1 not taken.
100864 if(!p_igetl(&tempitem.weapduration,f))
6835 {
6836 return qe_invalid;
6837 }
6838
2/2
✓ Branch 0 taken 1008640 times.
✓ Branch 1 taken 100864 times.
1109504 for ( int32_t q = 0; q < ITEM_MOVEMENT_PATTERNS; q++ )
6839 {
6840
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1008640 times.
1008640 if(!p_igetl(&tempitem.weap_pattern[q],f))
6841 {
6842 return qe_invalid;
6843 }
6844 1008640 }
6845 100864 }
6846
6847
2/2
✓ Branch 0 taken 33792 times.
✓ Branch 1 taken 100864 times.
134656 if ( s_version >= 27 ) //! New itemdata vars for weapon editor. -Z
6848 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6849
1/2
✓ Branch 0 taken 100864 times.
✗ Branch 1 not taken.
100864 if(!p_igetl(&tempitem.duplicates,f))
6850 {
6851 return qe_invalid;
6852 }
6853
2/2
✓ Branch 0 taken 806912 times.
✓ Branch 1 taken 100864 times.
907776 for ( int32_t q = 0; q < INITIAL_D; q++ )
6854 {
6855
1/2
✓ Branch 0 taken 806912 times.
✗ Branch 1 not taken.
806912 if(!p_igetl(&tempitem.weap_initiald[q],f))
6856 {
6857 return qe_invalid;
6858 }
6859 806912 }
6860
2/2
✓ Branch 0 taken 201728 times.
✓ Branch 1 taken 100864 times.
302592 for ( int32_t q = 0; q < INITIAL_A; q++ )
6861 {
6862
1/2
✓ Branch 0 taken 201728 times.
✗ Branch 1 not taken.
201728 if(!p_getc(&tempitem.weap_initiala[q],f))
6863 {
6864 return qe_invalid;
6865 }
6866 201728 }
6867
6868
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100864 times.
100864 if(!p_getc(&tempitem.drawlayer,f))
6869 {
6870 return qe_invalid;
6871 }
6872
6873
6874
1/2
✓ Branch 0 taken 100864 times.
✗ Branch 1 not taken.
100864 if(!p_igetl(&tempitem.hxofs,f))
6875 {
6876 return qe_invalid;
6877 }
6878
1/2
✓ Branch 0 taken 100864 times.
✗ Branch 1 not taken.
100864 if(!p_igetl(&tempitem.hyofs,f))
6879 {
6880 return qe_invalid;
6881 }
6882
1/2
✓ Branch 0 taken 100864 times.
✗ Branch 1 not taken.
100864 if(!p_igetl(&tempitem.hxsz,f))
6883 {
6884 return qe_invalid;
6885 }
6886
1/2
✓ Branch 0 taken 100864 times.
✗ Branch 1 not taken.
100864 if(!p_igetl(&tempitem.hysz,f))
6887 {
6888 return qe_invalid;
6889 }
6890
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100864 times.
100864 if(!p_igetl(&tempitem.hzsz,f))
6891 {
6892 return qe_invalid;
6893 }
6894
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100864 times.
100864 if(!p_igetl(&tempitem.xofs,f))
6895 {
6896 return qe_invalid;
6897 }
6898
1/2
✓ Branch 0 taken 100864 times.
✗ Branch 1 not taken.
100864 if(!p_igetl(&tempitem.yofs,f))
6899 {
6900 return qe_invalid;
6901 }
6902
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100864 times.
100864 if(!p_igetl(&tempitem.weap_hxofs,f))
6903 {
6904 return qe_invalid;
6905 }
6906
1/2
✓ Branch 0 taken 100864 times.
✗ Branch 1 not taken.
100864 if(!p_igetl(&tempitem.weap_hyofs,f))
6907 {
6908 return qe_invalid;
6909 }
6910
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100864 times.
100864 if(!p_igetl(&tempitem.weap_hxsz,f))
6911 {
6912 return qe_invalid;
6913 }
6914
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100864 times.
100864 if(!p_igetl(&tempitem.weap_hysz,f))
6915 {
6916 return qe_invalid;
6917 }
6918
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100864 times.
100864 if(!p_igetl(&tempitem.weap_hzsz,f))
6919 {
6920 return qe_invalid;
6921 }
6922
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100864 times.
100864 if(!p_igetl(&tempitem.weap_xofs,f))
6923 {
6924 return qe_invalid;
6925 }
6926
1/2
✓ Branch 0 taken 100864 times.
✗ Branch 1 not taken.
100864 if(!p_igetl(&tempitem.weap_yofs,f))
6927 {
6928 return qe_invalid;
6929 }
6930
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100864 times.
100864 if(!p_igetw(&tempitem.weaponscript,f))
6931 {
6932 return qe_invalid;
6933 }
6934
1/2
✓ Branch 0 taken 100864 times.
✗ Branch 1 not taken.
100864 if(!p_igetl(&tempitem.wpnsprite,f))
6935 {
6936 return qe_invalid;
6937 }
6938 100864 auto num_cost_tmr = (s_version > 52 ? 2 : 1);
6939
2/2
✓ Branch 0 taken 201728 times.
✓ Branch 1 taken 100864 times.
302592 for(auto q = 0; q < num_cost_tmr; ++q)
6940 {
6941
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 201728 times.
201728 if(!p_igetl(&tempitem.magiccosttimer[q],f))
6942 {
6943 return qe_invalid;
6944 }
6945 201728 }
6946
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100864 times.
100864 for(auto q = num_cost_tmr; q < 2; ++q)
6947 tempitem.magiccosttimer[q] = 0;
6948 100864 }
6949
2/2
✓ Branch 0 taken 33792 times.
✓ Branch 1 taken 100864 times.
134656 if ( s_version >= 28 ) //! New itemdata vars for weapon editor. -Z
6950 {
6951 //Item Size FLags, TileWidth, TileHeight
6952
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100864 times.
100864 if(!p_igetl(&tempitem.overrideFLAGS,f))
6953 {
6954 return qe_invalid;
6955 }
6956
1/2
✓ Branch 0 taken 100864 times.
✗ Branch 1 not taken.
100864 if(!p_igetl(&tempitem.tilew,f))
6957 {
6958 return qe_invalid;
6959 }
6960
1/2
✓ Branch 0 taken 100864 times.
✗ Branch 1 not taken.
100864 if(!p_igetl(&tempitem.tileh,f))
6961 {
6962 return qe_invalid;
6963 }
6964 100864 }
6965
2/2
✓ Branch 0 taken 33792 times.
✓ Branch 1 taken 100864 times.
134656 if ( s_version >= 29 ) //! More new vars.
6966 {
6967 //Item Size FLags, TileWidth, TileHeight
6968
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100864 times.
100864 if(!p_igetl(&tempitem.weapoverrideFLAGS,f))
6969 {
6970 return qe_invalid;
6971 }
6972
1/2
✓ Branch 0 taken 100864 times.
✗ Branch 1 not taken.
100864 if(!p_igetl(&tempitem.weap_tilew,f))
6973 {
6974 return qe_invalid;
6975 }
6976
1/2
✓ Branch 0 taken 100864 times.
✗ Branch 1 not taken.
100864 if(!p_igetl(&tempitem.weap_tileh,f))
6977 {
6978 return qe_invalid;
6979 }
6980 100864 }
6981
2/2
✓ Branch 0 taken 33792 times.
✓ Branch 1 taken 100864 times.
134656 if ( s_version >= 30 ) //! More new vars.
6982 {
6983 //Pickup Type
6984
1/2
✓ Branch 0 taken 100864 times.
✗ Branch 1 not taken.
100864 if(!p_igetl(&tempitem.pickup,f))
6985 {
6986 return qe_invalid;
6987 }
6988 100864 }
6989
2/2
✓ Branch 0 taken 33792 times.
✓ Branch 1 taken 100864 times.
134656 if ( s_version >= 32 ) //! More new vars.
6990 {
6991 //Pickup Type
6992
1/2
✓ Branch 0 taken 100864 times.
✗ Branch 1 not taken.
100864 if(!p_igetw(&tempitem.pstring,f))
6993 {
6994 return qe_invalid;
6995 }
6996 100864 }
6997
2/2
✓ Branch 0 taken 33792 times.
✓ Branch 1 taken 100864 times.
134656 if ( s_version >= 33 ) //! More new vars.
6998 {
6999 //Pickup Type
7000
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100864 times.
100864 if(!p_igetw(&tempitem.pickup_string_flags,f))
7001 {
7002 return qe_invalid;
7003 }
7004 100864 }
7005
2/2
✓ Branch 0 taken 33792 times.
✓ Branch 1 taken 100864 times.
134656 if ( s_version >= 34 ) //! cost counter
7006 {
7007
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100864 times.
100864 if(s_version < 53)
7008 {
7009 if(!p_getc(&tempitem.cost_counter[0],f))
7010 {
7011 return qe_invalid;
7012 }
7013 }
7014 else
7015 {
7016
2/2
✓ Branch 0 taken 201728 times.
✓ Branch 1 taken 100864 times.
302592 for(auto q = 0; q < 2; ++q)
7017 {
7018
1/2
✓ Branch 0 taken 201728 times.
✗ Branch 1 not taken.
201728 if(!p_getc(&tempitem.cost_counter[q],f))
7019 {
7020 return qe_invalid;
7021 }
7022 201728 }
7023 }
7024 100864 }
7025
2/2
✓ Branch 0 taken 33792 times.
✓ Branch 1 taken 100864 times.
134656 if ( s_version >= 44 ) //! sprite scripts
7026 {
7027
2/2
✓ Branch 0 taken 806912 times.
✓ Branch 1 taken 100864 times.
907776 for ( int32_t q = 0; q < 8; q++ )
7028 {
7029
2/2
✓ Branch 0 taken 52449280 times.
✓ Branch 1 taken 806912 times.
53256192 for ( int32_t w = 0; w < 65; w++ )
7030 {
7031
1/2
✓ Branch 0 taken 52449280 times.
✗ Branch 1 not taken.
52449280 if(!p_getc(&(tempitem.initD_label[q][w]),f))
7032 {
7033 return qe_invalid;
7034 }
7035 52449280 }
7036
2/2
✓ Branch 0 taken 52449280 times.
✓ Branch 1 taken 806912 times.
53256192 for ( int32_t w = 0; w < 65; w++ )
7037 {
7038
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52449280 times.
52449280 if(!p_getc(&(tempitem.weapon_initD_label[q][w]),f))
7039 {
7040 return qe_invalid;
7041 }
7042 52449280 }
7043
2/2
✓ Branch 0 taken 52449280 times.
✓ Branch 1 taken 806912 times.
53256192 for ( int32_t w = 0; w < 65; w++ )
7044 {
7045
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52449280 times.
52449280 if(!p_getc(&(tempitem.sprite_initD_label[q][w]),f))
7046 {
7047 return qe_invalid;
7048 }
7049 52449280 }
7050
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 806912 times.
806912 if(!p_igetl(&(tempitem.sprite_initiald[q]),f))
7051 {
7052 return qe_invalid;
7053 }
7054
7055 806912 }
7056
2/2
✓ Branch 0 taken 201728 times.
✓ Branch 1 taken 100864 times.
302592 for ( int32_t q = 0; q < 2; q++ )
7057 {
7058
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 201728 times.
201728 if(!p_getc(&(tempitem.sprite_initiala[q]),f))
7059 {
7060 return qe_invalid;
7061 }
7062 201728 }
7063 //Pickup Type
7064
1/2
✓ Branch 0 taken 100864 times.
✗ Branch 1 not taken.
100864 if(!p_igetw(&tempitem.sprite_script,f))
7065 {
7066 return qe_invalid;
7067 }
7068 100864 }
7069
2/2
✓ Branch 0 taken 33792 times.
✓ Branch 1 taken 100864 times.
134656 if ( s_version >= 48 ) //! pickup flags
7070 {
7071
1/2
✓ Branch 0 taken 100864 times.
✗ Branch 1 not taken.
100864 if(!p_getc(&(tempitem.pickupflag),f))
7072 {
7073 return qe_invalid;
7074 }
7075 100864 }
7076
2/2
✓ Branch 0 taken 37120 times.
✓ Branch 1 taken 97536 times.
134656 if ( s_version >= 57 )
7077 {
7078 97536 std::string str;
7079
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 97536 times.
✓ Branch 2 taken 97536 times.
✗ Branch 3 not taken.
97536 if(!p_getcstr(&str,f))
7080 return qe_invalid;
7081 97536 strncpy(tempitem.display_name,str.c_str(),255);
7082
1/3
✓ Branch 0 taken 97536 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
97536 }
7083 134656 }
7084 else
7085 {
7086 2730 tempitem.count=-1;
7087 2730 tempitem.family=itype_misc;
7088 2730 tempitem.flags=tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
7089 2730 tempitem.playsound=WAV_SCALE;
7090 2730 reset_itembuf(&tempitem,i);
7091 }
7092
7093
2/2
✓ Branch 0 taken 41130 times.
✓ Branch 1 taken 96256 times.
137386 if(s_version >= 58)
7094 {
7095
2/2
✓ Branch 0 taken 481280 times.
✓ Branch 1 taken 96256 times.
577536 for(int q = 0; q < BURNSPR_MAX; ++q)
7096 {
7097
1/2
✓ Branch 0 taken 481280 times.
✗ Branch 1 not taken.
481280 if(!p_getc(&tempitem.burnsprs[q],f))
7098 return qe_invalid;
7099
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 481280 times.
481280 if(s_version >= 59)
7100
1/2
✓ Branch 0 taken 481280 times.
✗ Branch 1 not taken.
481280 if(!p_getc(&tempitem.light_rads[q],f))
7101 return qe_invalid;
7102 481280 }
7103 96256 }
7104
7105
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137386 times.
137386 if (!should_skip)
7106 {
7107
1/2
✓ Branch 0 taken 137386 times.
✗ Branch 1 not taken.
137386 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
7108 {
7109 tempitem.script = 0;
7110 tempitem.weaponscript = 0;
7111 for(int q = 0; q < 8; ++q)
7112 {
7113 tempitem.initiald[q] = 0;
7114 tempitem.weap_initiald[q] = 0;
7115 }
7116 }
7117 137386 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
7118 137386 }
7119 137386 }
7120
7121
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 588 times.
589 if (should_skip)
7122 1 return 0;
7123
7124 //////////////////////////////////////////////////////
7125 // Now do any updates because of new item additions
7126 // (These can't be done above because items_to_read
7127 // might be too low.)
7128 //////////////////////////////////////////////////////
7129
2/2
✓ Branch 0 taken 150528 times.
✓ Branch 1 taken 588 times.
151116 for(int32_t i=0; i<MAXITEMS; i++)
7130 {
7131 150528 memcpy(&tempitem, &itemsbuf[i], sizeof(itemdata));
7132
7133 //Account for older quests that didn't have an actual item for the used letter
7134
4/4
✓ Branch 0 taken 15872 times.
✓ Branch 1 taken 134656 times.
✓ Branch 2 taken 15810 times.
✓ Branch 3 taken 62 times.
150528 if(s_version < 2 && i==iLetterUsed)
7135 {
7136 62 reset_itembuf(&tempitem, iLetterUsed);
7137 62 strcpy(item_string[i],old_item_string[i]);
7138 62 tempitem.tile = itemsbuf[iLetter].tile;
7139 62 tempitem.csets = itemsbuf[iLetter].csets;
7140 62 tempitem.misc_flags = itemsbuf[iLetter].misc_flags;
7141 62 tempitem.frames = itemsbuf[iLetter].frames;
7142 62 tempitem.speed = itemsbuf[iLetter].speed;
7143 62 tempitem.ltm = itemsbuf[iLetter].ltm;
7144 62 }
7145
7146
2/2
✓ Branch 0 taken 134656 times.
✓ Branch 1 taken 15872 times.
150528 if(s_version < 3)
7147 {
7148
3/3
✓ Branch 0 taken 1364 times.
✓ Branch 1 taken 14446 times.
✓ Branch 2 taken 62 times.
15872 switch(i)
7149 {
7150 case iRocsFeather:
7151 case iHoverBoots:
7152 case iSpinScroll:
7153 case iL2SpinScroll:
7154 case iCrossScroll:
7155 case iQuakeScroll:
7156 case iL2QuakeScroll:
7157 case iWhispRing:
7158 case iL2WhispRing:
7159 case iChargeRing:
7160 case iL2ChargeRing:
7161 case iPerilScroll:
7162 case iWalletL3:
7163 case iQuiverL4:
7164 case iBombBagL4:
7165 case iBracelet:
7166 case iL2Bracelet:
7167 case iOldGlove:
7168 case iL2Ladder:
7169 case iWealthMedal:
7170 case iL2WealthMedal:
7171 case iL3WealthMedal:
7172 1364 reset_itembuf(&tempitem, i);
7173 1364 strcpy(item_string[i],old_item_string[i]);
7174 1364 break;
7175
7176 case iSShield:
7177 62 reset_itembuf(&tempitem, i);
7178 62 strcpy(item_string[i],old_item_string[i]);
7179 62 strcpy(item_string[iShield],old_item_string[iShield]);
7180 62 strcpy(item_string[iMShield],old_item_string[iMShield]);
7181 62 break;
7182 }
7183 15872 }
7184
7185
2/2
✓ Branch 0 taken 134656 times.
✓ Branch 1 taken 15872 times.
150528 if(s_version < 5)
7186 {
7187
2/2
✓ Branch 0 taken 434 times.
✓ Branch 1 taken 15438 times.
15872 switch(i)
7188 {
7189 case iHeartRing:
7190 case iL2HeartRing:
7191 case iL3HeartRing:
7192 case iMagicRing:
7193 case iL2MagicRing:
7194 case iL3MagicRing:
7195 case iL4MagicRing:
7196 434 reset_itembuf(&tempitem, i);
7197 434 strcpy(item_string[i],old_item_string[i]);
7198 434 break;
7199 }
7200 15872 }
7201
7202
2/2
✓ Branch 0 taken 134656 times.
✓ Branch 1 taken 15872 times.
150528 if(s_version < 6) // April 2007: Advanced item editing capabilities.
7203 {
7204
4/4
✓ Branch 0 taken 15810 times.
✓ Branch 1 taken 62 times.
✓ Branch 2 taken 62 times.
✓ Branch 3 taken 15748 times.
15872 if(i!=iBPotion && i!=iRPotion)
7205 15748 tempitem.flags |= get_bit(deprecated_rules,32) ? ITEM_KEEPOLD : 0;
7206
7207
43/43
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 62 times.
✓ Branch 2 taken 62 times.
✓ Branch 3 taken 62 times.
✓ Branch 4 taken 62 times.
✓ Branch 5 taken 62 times.
✓ Branch 6 taken 62 times.
✓ Branch 7 taken 248 times.
✓ Branch 8 taken 13082 times.
✓ Branch 9 taken 62 times.
✓ Branch 10 taken 62 times.
✓ Branch 11 taken 62 times.
✓ Branch 12 taken 62 times.
✓ Branch 13 taken 62 times.
✓ Branch 14 taken 62 times.
✓ Branch 15 taken 62 times.
✓ Branch 16 taken 62 times.
✓ Branch 17 taken 62 times.
✓ Branch 18 taken 62 times.
✓ Branch 19 taken 62 times.
✓ Branch 20 taken 62 times.
✓ Branch 21 taken 62 times.
✓ Branch 22 taken 62 times.
✓ Branch 23 taken 62 times.
✓ Branch 24 taken 62 times.
✓ Branch 25 taken 62 times.
✓ Branch 26 taken 62 times.
✓ Branch 27 taken 62 times.
✓ Branch 28 taken 62 times.
✓ Branch 29 taken 62 times.
✓ Branch 30 taken 62 times.
✓ Branch 31 taken 62 times.
✓ Branch 32 taken 62 times.
✓ Branch 33 taken 62 times.
✓ Branch 34 taken 62 times.
✓ Branch 35 taken 62 times.
✓ Branch 36 taken 62 times.
✓ Branch 37 taken 62 times.
✓ Branch 38 taken 62 times.
✓ Branch 39 taken 62 times.
✓ Branch 40 taken 62 times.
✓ Branch 41 taken 62 times.
✓ Branch 42 taken 62 times.
15872 switch(i)
7208 {
7209 case iTriforce:
7210 62 tempitem.fam_type=1;
7211 62 break;
7212
7213 case iBigTri:
7214 62 tempitem.fam_type=0;
7215 62 break;
7216
7217 case iBombs:
7218 62 tempitem.fam_type=i_bomb;
7219 62 tempitem.power=4;
7220 62 tempitem.wpn=wBOMB;
7221 62 tempitem.wpn2=wBOOM;
7222 62 tempitem.misc1 = 50;
7223
7224
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(get_bit(deprecated_rules,qr_SLOWBOMBFUSES_DEP)) tempitem.misc1 = 200;
7225
7226 62 break;
7227
7228 case iSBomb:
7229 62 tempitem.fam_type=i_sbomb;
7230 62 tempitem.power=16;
7231 62 tempitem.wpn=wSBOMB;
7232 62 tempitem.wpn2=wSBOOM;
7233 62 tempitem.misc1 = 50;
7234
7235
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(get_bit(deprecated_rules,qr_SLOWBOMBFUSES_DEP)) tempitem.misc1 = 400;
7236
7237 62 break;
7238
7239 case iBook:
7240
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(get_bit(deprecated_rules, qr_FIREMAGICSPRITE_DEP))
7241 tempitem.wpn = wFIREMAGIC;
7242
7243 62 break;
7244
7245 case iSArrow:
7246 62 tempitem.wpn2 = get_bit(deprecated_rules,27) ? wSSPARKLE : 0; //qr_SASPARKLES
7247 62 tempitem.power=4;
7248 62 tempitem.flags|=ITEM_GAMEDATA;
7249 62 tempitem.wpn=wSARROW;
7250 62 break;
7251
7252 case iGArrow:
7253 62 tempitem.wpn2 = get_bit(deprecated_rules,28) ? wGSPARKLE : 0; //qr_GASPARKLES
7254 62 tempitem.power=8;
7255 62 tempitem.flags|=(ITEM_GAMEDATA|ITEM_FLAG1);
7256 62 tempitem.wpn=wGARROW;
7257 62 break;
7258
7259 case iBrang:
7260 62 tempitem.power=0;
7261 62 tempitem.wpn=wBRANG;
7262 62 tempitem.misc1=36;
7263 62 break;
7264
7265 case iMBrang:
7266 62 tempitem.wpn2 = get_bit(deprecated_rules,29) ? wMSPARKLE : 0; //qr_MBSPARKLES
7267 62 tempitem.power=0;
7268 62 tempitem.wpn=wMBRANG;
7269 62 break;
7270
7271 case iFBrang:
7272 62 tempitem.wpn3 = get_bit(deprecated_rules,30) ? wFSPARKLE : 0; //qr_FBSPARKLES
7273 62 tempitem.power=2;
7274 62 tempitem.wpn=wFBRANG;
7275 62 break;
7276
7277 case iBoots:
7278 62 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICBOOTS_DEP) ? 1 : 0;
7279 62 tempitem.power=7;
7280 62 break;
7281
7282 case iWand:
7283 62 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICWAND_DEP) ? 8 : 0;
7284 62 tempitem.power=2;
7285 62 tempitem.wpn=wWAND;
7286 62 tempitem.wpn3=wMAGIC;
7287 62 break;
7288
7289 case iBCandle:
7290 62 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICCANDLE_DEP) ? 4 : 0;
7291 62 tempitem.power=1;
7292 62 tempitem.flags|=(ITEM_GAMEDATA|ITEM_FLAG1);
7293 62 tempitem.wpn3=wFIRE;
7294 62 break;
7295
7296 case iRCandle:
7297 62 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICCANDLE_DEP) ? 4 : 0;
7298 62 tempitem.power=1;
7299 62 tempitem.wpn3=wFIRE;
7300 62 break;
7301
7302 case iSword:
7303 62 tempitem.power=1;
7304 62 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7305 62 tempitem.wpn=tempitem.wpn3=wSWORD;
7306 62 tempitem.wpn2=wSWORDSLASH;
7307 62 break;
7308
7309 case iWSword:
7310 62 tempitem.power=2;
7311 62 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7312 62 tempitem.wpn=tempitem.wpn3=wWSWORD;
7313 62 tempitem.wpn2=wWSWORDSLASH;
7314 62 break;
7315
7316 case iMSword:
7317 62 tempitem.power=4;
7318 62 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7319 62 tempitem.wpn=tempitem.wpn3=wMSWORD;
7320 62 tempitem.wpn2=wMSWORDSLASH;
7321 62 break;
7322
7323 case iXSword:
7324 62 tempitem.power=8;
7325 62 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7326 62 tempitem.wpn=tempitem.wpn3=wXSWORD;
7327 62 tempitem.wpn2=wXSWORDSLASH;
7328 62 break;
7329
7330 case iDivineProtection:
7331 62 tempitem.flags |= get_bit(deprecated_rules,qr_FLICKERINGDIVINEPROTECTIONROCKET_DEP) ? ITEM_FLAG1 : 0;
7332 62 tempitem.flags |= get_bit(deprecated_rules,qr_TRANSLUCENTDIVINEPROTECTIONROCKET_DEP) ? ITEM_FLAG2 : 0;
7333 62 tempitem.wpn=wDIVINEPROTECTION1A;
7334 62 tempitem.wpn2=wDIVINEPROTECTION1B;
7335 62 tempitem.wpn3=wDIVINEPROTECTIONS1A;
7336 62 tempitem.wpn4=wDIVINEPROTECTIONS1B;
7337 62 tempitem.wpn6=wDIVINEPROTECTION2A;
7338 62 tempitem.wpn7=wDIVINEPROTECTION2B;
7339 62 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7340 62 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7341 62 tempitem.wpn5 = iwDivineProtectionShieldFront;
7342 62 tempitem.wpn10 = iwDivineProtectionShieldBack;
7343 62 tempitem.misc1=512;
7344 62 tempitem.cost_amount[0]=64;
7345 62 break;
7346
7347 case iLens:
7348 62 tempitem.misc1=60;
7349 62 tempitem.flags |= get_qr(qr_ENABLEMAGIC) ? 0 : ITEM_RUPEE_MAGIC;
7350 62 tempitem.cost_amount[0] = get_qr(qr_ENABLEMAGIC) ? 2 : 1;
7351 62 break;
7352
7353 case iArrow:
7354 62 tempitem.power=2;
7355 62 tempitem.wpn=wARROW;
7356 62 break;
7357
7358 case iHoverBoots:
7359 62 tempitem.misc1=45;
7360 62 tempitem.wpn=iwHover;
7361 62 break;
7362
7363 case iDivineFire:
7364 62 tempitem.power=8;
7365 62 tempitem.wpn=wDIVINEFIRE1A;
7366 62 tempitem.wpn2=wDIVINEFIRE1B;
7367 62 tempitem.wpn3=wDIVINEFIRES1A;
7368 62 tempitem.wpn4=wDIVINEFIRES1B;
7369 62 tempitem.misc1 = 32;
7370 62 tempitem.misc2 = 200;
7371 62 tempitem.cost_amount[0]=32;
7372 62 break;
7373
7374 case iDivineEscape:
7375 62 tempitem.cost_amount[0]=32;
7376 62 break;
7377
7378 case iHookshot:
7379 62 tempitem.power=0;
7380 62 tempitem.flags&=~ITEM_FLAG1;
7381 62 tempitem.wpn=wHSHEAD;
7382 62 tempitem.wpn2=wHSCHAIN_H;
7383 62 tempitem.wpn4=wHSHANDLE;
7384 62 tempitem.wpn3=wHSCHAIN_V;
7385 62 tempitem.misc1=50;
7386 62 tempitem.misc2=100;
7387 62 break;
7388
7389 case iLongshot:
7390 62 tempitem.power=0;
7391 62 tempitem.flags&=~ITEM_FLAG1;
7392 62 tempitem.wpn=wLSHEAD;
7393 62 tempitem.wpn2=wLSCHAIN_H;
7394 62 tempitem.wpn4=wLSHANDLE;
7395 62 tempitem.wpn3=wLSCHAIN_V;
7396 62 tempitem.misc1=99;
7397 62 tempitem.misc2=100;
7398 62 break;
7399
7400 case iHammer:
7401 62 tempitem.power=4;
7402 62 tempitem.wpn=wHAMMER;
7403 62 tempitem.wpn2=iwHammerSmack;
7404 62 break;
7405
7406 case iCByrna:
7407 62 tempitem.power=1;
7408 62 tempitem.wpn=wCBYRNA;
7409 62 tempitem.wpn2=wCBYRNASLASH;
7410 62 tempitem.wpn3=wCBYRNAORB;
7411 62 tempitem.misc1=4;
7412 62 tempitem.misc2=16;
7413 62 tempitem.misc3=1;
7414 62 tempitem.cost_amount[0]=1;
7415 62 break;
7416
7417 case iWhistle:
7418 62 tempitem.wpn=wWIND;
7419 62 tempitem.misc1=3;
7420 62 tempitem.flags|=ITEM_FLAG1;
7421 62 break;
7422
7423 case iBRing:
7424 62 tempitem.power=2;
7425 62 tempitem.misc1=spBLUE;
7426 62 break;
7427
7428 case iRRing:
7429 62 tempitem.power=4;
7430 62 tempitem.misc1=spRED;
7431 62 break;
7432
7433 case iGRing:
7434 62 tempitem.power=8;
7435 62 tempitem.misc1=spGOLD;
7436 62 break;
7437
7438 case iSpinScroll:
7439 62 tempitem.power = 2;
7440 62 tempitem.misc1 = 1;
7441 62 break;
7442
7443 case iL2SpinScroll:
7444 62 tempitem.family=itype_spinscroll2;
7445 62 tempitem.fam_type=1;
7446 62 tempitem.cost_amount[0]=8;
7447 62 tempitem.power=2;
7448 62 tempitem.misc1 = 20;
7449 62 break;
7450
7451 case iQuakeScroll:
7452 62 tempitem.misc1=0x10;
7453 62 tempitem.misc2=64;
7454 62 break;
7455
7456 case iL2QuakeScroll:
7457 62 tempitem.family=itype_quakescroll2;
7458 62 tempitem.fam_type=1;
7459 62 tempitem.power = 2;
7460 62 tempitem.misc1=0x20;
7461 62 tempitem.misc2=192;
7462 62 tempitem.cost_amount[0]=8;
7463 62 break;
7464
7465 case iChargeRing:
7466 62 tempitem.misc1=64;
7467 62 tempitem.misc2=128;
7468 62 break;
7469
7470 case iL2ChargeRing:
7471 62 tempitem.misc1=32;
7472 62 tempitem.misc2=64;
7473 62 break;
7474
7475 case iOldGlove:
7476 62 tempitem.flags |= ITEM_FLAG1;
7477
7478 //fallthrough
7479 case iBombBagL4:
7480 case iWalletL3:
7481 case iQuiverL4:
7482 case iBracelet:
7483 310 tempitem.power = 1;
7484 310 break;
7485
7486 case iL2Bracelet:
7487 62 tempitem.power = 2;
7488 62 break;
7489
7490 case iMKey:
7491 62 tempitem.power=0xFF;
7492 62 tempitem.flags |= ITEM_FLAG1;
7493 62 break;
7494 }
7495 15872 }
7496
7497
2/2
✓ Branch 0 taken 134656 times.
✓ Branch 1 taken 15872 times.
150528 if(s_version < 7)
7498 {
7499
2/2
✓ Branch 0 taken 248 times.
✓ Branch 1 taken 15624 times.
15872 switch(i)
7500 {
7501 case iStoneAgony:
7502 case iStompBoots:
7503 case iPerilRing:
7504 case iWhimsicalRing:
7505 {
7506 248 reset_itembuf(&tempitem, i);
7507 248 strcpy(item_string[i],old_item_string[i]);
7508 248 break;
7509 }
7510 }
7511 15872 }
7512
7513
2/2
✓ Branch 0 taken 134656 times.
✓ Branch 1 taken 15872 times.
150528 if(s_version < 8) // May 2007: Some corrections.
7514 {
7515
7/7
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 186 times.
✓ Branch 2 taken 15376 times.
✓ Branch 3 taken 62 times.
✓ Branch 4 taken 62 times.
✓ Branch 5 taken 62 times.
✓ Branch 6 taken 62 times.
15872 switch(i)
7516 {
7517 case iMShield:
7518 62 tempitem.misc1|=shFLAME;
7519 62 tempitem.misc2|=shFIREBALL|shMAGIC;
7520
7521
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(get_qr(qr_SWORDMIRROR))
7522 {
7523 tempitem.misc2 |= shSWORD;
7524 }
7525
7526 // fallthrough
7527 case iShield:
7528 124 tempitem.misc1|=shFIREBALL|shSWORD|shMAGIC;
7529
7530 // fallthrough
7531 case iSShield:
7532 186 tempitem.misc1|=shROCK|shARROW|shBRANG|shSCRIPT;
7533
7534
1/2
✓ Branch 0 taken 186 times.
✗ Branch 1 not taken.
186 if(get_bit(deprecated_rules,102)) //qr_REFLECTROCKS
7535 {
7536 tempitem.misc2 |= shROCK;
7537 }
7538
7539 186 break;
7540
7541 case iWhispRing:
7542 62 tempitem.power=1;
7543 62 tempitem.flags|=ITEM_GAMEDATA|ITEM_FLAG1;
7544 62 tempitem.misc1 = 3;
7545 62 break;
7546
7547 case iL2WhispRing:
7548 62 tempitem.power=0;
7549 62 tempitem.flags|=ITEM_GAMEDATA|ITEM_FLAG1;
7550 62 tempitem.misc1 = 3;
7551 62 break;
7552
7553 case iL2Ladder:
7554 case iBow:
7555 case iCByrna:
7556 186 tempitem.power = 1;
7557 186 break;
7558 }
7559 15872 }
7560
7561
4/4
✓ Branch 0 taken 15872 times.
✓ Branch 1 taken 134656 times.
✓ Branch 2 taken 15810 times.
✓ Branch 3 taken 62 times.
150528 if(s_version < 9 && i==iClock)
7562 {
7563 62 tempitem.misc1 = get_bit(deprecated_rules, qr_TEMPCLOCKS_DEP) ? 256 : 0;
7564 62 }
7565
7566 //add the misc flag for bomb
7567
4/4
✓ Branch 0 taken 15872 times.
✓ Branch 1 taken 134656 times.
✓ Branch 2 taken 15810 times.
✓ Branch 3 taken 62 times.
150528 if(s_version < 10 && tempitem.family == itype_bomb)
7568 {
7569 62 tempitem.flags = (tempitem.flags & ~ITEM_FLAG1) | (get_qr(qr_LONGBOMBBOOM_DEP) ? ITEM_FLAG1 : 0);
7570 62 }
7571
7572
4/4
✓ Branch 0 taken 15872 times.
✓ Branch 1 taken 134656 times.
✓ Branch 2 taken 15748 times.
✓ Branch 3 taken 124 times.
150528 if(s_version < 11 && tempitem.family == itype_triforcepiece)
7573 {
7574 124 tempitem.flags = (tempitem.fam_type ? ITEM_GAMEDATA : 0);
7575 124 tempitem.playsound = (tempitem.fam_type ? WAV_SCALE : WAV_CLEARED);
7576 124 }
7577
7578
2/2
✓ Branch 0 taken 134656 times.
✓ Branch 1 taken 15872 times.
150528 if(s_version < 12) // June 2007: More Misc. attributes.
7579 {
7580
5/5
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 124 times.
✓ Branch 2 taken 15562 times.
✓ Branch 3 taken 62 times.
✓ Branch 4 taken 62 times.
15872 switch(i)
7581 {
7582 case iFBrang:
7583 62 tempitem.misc4 |= shFIREBALL|shSWORD|shMAGIC;
7584
7585 //fallthrough
7586 case iMBrang:
7587 124 tempitem.misc3 |= shSWORD|shMAGIC;
7588
7589 //fallthrough
7590 case iHookshot:
7591 case iLongshot:
7592 //fallthrough
7593 248 tempitem.misc3 |= shFIREBALL;
7594
7595 case iBrang:
7596 310 tempitem.misc3 |= shBRANG|shROCK|shARROW;
7597 310 break;
7598 }
7599
7600
16/16
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 62 times.
✓ Branch 2 taken 62 times.
✓ Branch 3 taken 186 times.
✓ Branch 4 taken 186 times.
✓ Branch 5 taken 62 times.
✓ Branch 6 taken 62 times.
✓ Branch 7 taken 62 times.
✓ Branch 8 taken 248 times.
✓ Branch 9 taken 124 times.
✓ Branch 10 taken 7749 times.
✓ Branch 11 taken 124 times.
✓ Branch 12 taken 186 times.
✓ Branch 13 taken 6573 times.
✓ Branch 14 taken 62 times.
✓ Branch 15 taken 62 times.
15872 switch(tempitem.family)
7601 {
7602 case itype_hoverboots:
7603 62 tempitem.usesound = WAV_ZN1HOVER;
7604 62 break;
7605
7606 case itype_wand:
7607 62 tempitem.usesound = WAV_WAND;
7608 62 break;
7609
7610 case itype_book:
7611 62 tempitem.usesound = WAV_FIRE;
7612 62 break;
7613
7614 case itype_arrow:
7615 186 tempitem.usesound = WAV_ARROW;
7616 186 break;
7617
7618 case itype_hookshot:
7619 124 tempitem.usesound = WAV_HOOKSHOT;
7620 124 break;
7621
7622 case itype_brang:
7623 186 tempitem.usesound = WAV_BRANG;
7624 186 break;
7625
7626 case itype_shield:
7627 186 tempitem.usesound = WAV_CHINK;
7628 186 break;
7629
7630 case itype_sword:
7631 6573 tempitem.usesound = WAV_SWORD;
7632 6573 break;
7633
7634 case itype_whistle:
7635 62 tempitem.usesound = WAV_WHISTLE;
7636 62 break;
7637
7638 case itype_hammer:
7639 62 tempitem.usesound = WAV_HAMMER;
7640 62 break;
7641
7642 case itype_divinefire:
7643 62 tempitem.usesound = WAV_ZN1DIVINEFIRE;
7644 62 break;
7645
7646 case itype_divineescape:
7647 62 tempitem.usesound = WAV_ZN1DIVINEESCAPE;
7648 62 break;
7649
7650 case itype_divineprotection:
7651 62 tempitem.usesound = WAV_ZN1DIVINEPROTECTION1;
7652 62 break;
7653
7654 case itype_bomb:
7655 case itype_sbomb:
7656 case itype_quakescroll:
7657 case itype_quakescroll2:
7658 248 tempitem.usesound = WAV_BOMB;
7659 248 break;
7660
7661 case itype_spinscroll:
7662 case itype_spinscroll2:
7663 124 tempitem.usesound = WAV_ZN1SPINATTACK;
7664 124 break;
7665 }
7666 15872 }
7667
7668
2/2
✓ Branch 0 taken 134656 times.
✓ Branch 1 taken 15872 times.
150528 if(s_version < 13) // July 2007
7669 {
7670
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 15810 times.
15872 if(tempitem.family == itype_whistle)
7671 {
7672 62 tempitem.misc1 = (tempitem.power==2 ? 4 : 3);
7673 62 tempitem.power = 1;
7674 62 tempitem.flags|=ITEM_FLAG1;
7675 62 }
7676
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 15748 times.
15810 else if(tempitem.family == itype_wand)
7677 62 tempitem.flags|=ITEM_FLAG1;
7678
2/2
✓ Branch 0 taken 15686 times.
✓ Branch 1 taken 62 times.
15748 else if(tempitem.family == itype_book)
7679 {
7680 62 tempitem.flags|=ITEM_FLAG1;
7681 62 tempitem.power = 2;
7682 62 }
7683 15872 }
7684
7685
2/2
✓ Branch 0 taken 134656 times.
✓ Branch 1 taken 15872 times.
150528 if(s_version < 14) // August 2007
7686 {
7687
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 15748 times.
15872 if(tempitem.family == itype_fairy)
7688 {
7689 124 tempitem.usesound = WAV_SCALE;
7690
7691
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(tempitem.fam_type)
7692 124 tempitem.misc3=50;
7693 124 }
7694
2/2
✓ Branch 0 taken 15624 times.
✓ Branch 1 taken 124 times.
15748 else if(tempitem.family == itype_potion)
7695 {
7696 124 tempitem.flags |= ITEM_GAINOLD;
7697 124 }
7698 15872 }
7699
7700
2/2
✓ Branch 0 taken 134656 times.
✓ Branch 1 taken 15872 times.
150528 if(s_version < 17) // November 2007
7701 {
7702
3/4
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 15748 times.
✓ Branch 2 taken 124 times.
✗ Branch 3 not taken.
15872 if(tempitem.family == itype_candle && !tempitem.wpn3)
7703 {
7704 tempitem.wpn3 = wFIRE;
7705 }
7706
4/4
✓ Branch 0 taken 186 times.
✓ Branch 1 taken 15686 times.
✓ Branch 2 taken 124 times.
✓ Branch 3 taken 62 times.
15872 else if(tempitem.family == itype_arrow && tempitem.power>4)
7707 {
7708 62 tempitem.flags|=ITEM_FLAG1;
7709 62 }
7710 15872 }
7711
7712
2/2
✓ Branch 0 taken 134656 times.
✓ Branch 1 taken 15872 times.
150528 if(s_version < 18) // New Year's Eve 2007
7713 {
7714
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 15810 times.
15872 if(tempitem.family == itype_whistle)
7715 62 tempitem.misc2 = 8; // Use the Whistle warp ring
7716
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 15748 times.
15810 else if(tempitem.family == itype_bait)
7717 62 tempitem.misc1 = 768; // Frames until it goes
7718
2/2
✓ Branch 0 taken 15624 times.
✓ Branch 1 taken 124 times.
15748 else if(tempitem.family == itype_triforcepiece)
7719 {
7720
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 62 times.
124 if(tempitem.flags & ITEM_GAMEDATA)
7721 {
7722 62 tempitem.misc2 = 1; // Cutscene 1
7723 62 tempitem.flags |= ITEM_FLAG1; // Side Warp Out
7724 62 }
7725 124 }
7726 15872 }
7727
7728
2/2
✓ Branch 0 taken 134656 times.
✓ Branch 1 taken 15872 times.
150528 if(s_version < 19) // January 2008
7729 {
7730
2/2
✓ Branch 0 taken 15810 times.
✓ Branch 1 taken 62 times.
15872 if(tempitem.family == itype_divineprotection)
7731 {
7732 62 tempitem.flags |= get_bit(deprecated_rules,qr_NOBOMBPALFLASH+1)?ITEM_FLAG3:0;
7733 62 tempitem.flags |= get_bit(deprecated_rules,qr_NOBOMBPALFLASH+2)?ITEM_FLAG4:0;
7734 62 }
7735 15872 }
7736
7737
2/2
✓ Branch 0 taken 134656 times.
✓ Branch 1 taken 15872 times.
150528 if(s_version < 20) // October 2008
7738 {
7739
2/2
✓ Branch 0 taken 15810 times.
✓ Branch 1 taken 62 times.
15872 if(tempitem.family == itype_divineprotection)
7740 {
7741 62 tempitem.wpn6=wDIVINEPROTECTION2A;
7742 62 tempitem.wpn7=wDIVINEPROTECTION2B;
7743 62 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7744 62 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7745 62 tempitem.wpn5 = iwDivineProtectionShieldFront;
7746 62 tempitem.wpn10 = iwDivineProtectionShieldBack;
7747 62 }
7748 15872 }
7749
7750
2/2
✓ Branch 0 taken 134656 times.
✓ Branch 1 taken 15872 times.
150528 if(s_version < 21) // November 2008
7751 {
7752
1/2
✓ Branch 0 taken 15872 times.
✗ Branch 1 not taken.
15872 if(tempitem.flags & 0x0100) // ITEM_SLASH
7753 {
7754 tempitem.flags &= ~0x0100;
7755
7756 if(tempitem.family == itype_sword ||
7757 tempitem.family == itype_wand ||
7758 tempitem.family == itype_candle ||
7759 tempitem.family == itype_cbyrna)
7760 {
7761 tempitem.flags |= ITEM_FLAG4;
7762 }
7763 }
7764 15872 }
7765
7766
2/2
✓ Branch 0 taken 134656 times.
✓ Branch 1 taken 15872 times.
150528 if(s_version < 22) // September 2009
7767 {
7768
4/4
✓ Branch 0 taken 15810 times.
✓ Branch 1 taken 62 times.
✓ Branch 2 taken 62 times.
✓ Branch 3 taken 15748 times.
15872 if(tempitem.family == itype_sbomb || tempitem.family == itype_bomb)
7769 {
7770 124 tempitem.misc3 = tempitem.power/2;
7771 124 }
7772 15872 }
7773
7774
2/2
✓ Branch 0 taken 134656 times.
✓ Branch 1 taken 15872 times.
150528 if(s_version < 23) // March 2011
7775 {
7776
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 15810 times.
15872 if(tempitem.family == itype_divinefire)
7777 62 tempitem.wpn5 = wFIRE;
7778
2/2
✓ Branch 0 taken 15748 times.
✓ Branch 1 taken 62 times.
15810 else if(tempitem.family == itype_book)
7779 62 tempitem.wpn2 = wFIRE;
7780 15872 }
7781
7782 // Version 25: Bomb bags were acting as though "super bombs also" was checked
7783 // whether it was or not, and a lot of existing quests depended on the
7784 // incorrect behavior.
7785
2/2
✓ Branch 0 taken 134656 times.
✓ Branch 1 taken 15872 times.
150528 if(s_version < 25) // January 2012
7786 {
7787
2/2
✓ Branch 0 taken 15624 times.
✓ Branch 1 taken 248 times.
15872 if(tempitem.family == itype_bombbag)
7788 248 tempitem.flags |= 16;
7789
7790
2/2
✓ Branch 0 taken 15810 times.
✓ Branch 1 taken 62 times.
15872 if(tempitem.family == itype_divinefire)
7791 62 tempitem.flags |= ITEM_FLAG3; // Sideview gravity flag
7792 15872 }
7793
7794
2/2
✓ Branch 0 taken 100864 times.
✓ Branch 1 taken 49664 times.
150528 if( version < 0x254) //Nuke greyed-out flags/values from <=2.53, in case they are used in 2.54/2.55
7795 {
7796
60/60
✓ Branch 0 taken 13883 times.
✓ Branch 1 taken 582 times.
✓ Branch 2 taken 570 times.
✓ Branch 3 taken 426 times.
✓ Branch 4 taken 240 times.
✓ Branch 5 taken 194 times.
✓ Branch 6 taken 384 times.
✓ Branch 7 taken 407 times.
✓ Branch 8 taken 210 times.
✓ Branch 9 taken 630 times.
✓ Branch 10 taken 598 times.
✓ Branch 11 taken 380 times.
✓ Branch 12 taken 590 times.
✓ Branch 13 taken 384 times.
✓ Branch 14 taken 192 times.
✓ Branch 15 taken 384 times.
✓ Branch 16 taken 208 times.
✓ Branch 17 taken 192 times.
✓ Branch 18 taken 582 times.
✓ Branch 19 taken 194 times.
✓ Branch 20 taken 196 times.
✓ Branch 21 taken 386 times.
✓ Branch 22 taken 186 times.
✓ Branch 23 taken 194 times.
✓ Branch 24 taken 192 times.
✓ Branch 25 taken 192 times.
✓ Branch 26 taken 192 times.
✓ Branch 27 taken 208 times.
✓ Branch 28 taken 194 times.
✓ Branch 29 taken 194 times.
✓ Branch 30 taken 192 times.
✓ Branch 31 taken 196 times.
✓ Branch 32 taken 384 times.
✓ Branch 33 taken 768 times.
✓ Branch 34 taken 394 times.
✓ Branch 35 taken 192 times.
✓ Branch 36 taken 369 times.
✓ Branch 37 taken 768 times.
✓ Branch 38 taken 192 times.
✓ Branch 39 taken 192 times.
✓ Branch 40 taken 192 times.
✓ Branch 41 taken 192 times.
✓ Branch 42 taken 192 times.
✓ Branch 43 taken 386 times.
✓ Branch 44 taken 384 times.
✓ Branch 45 taken 192 times.
✓ Branch 46 taken 578 times.
✓ Branch 47 taken 580 times.
✓ Branch 48 taken 776 times.
✓ Branch 49 taken 192 times.
✓ Branch 50 taken 192 times.
✓ Branch 51 taken 192 times.
✓ Branch 52 taken 192 times.
✓ Branch 53 taken 192 times.
✓ Branch 54 taken 200 times.
✓ Branch 55 taken 6557 times.
✓ Branch 56 taken 1996 times.
✓ Branch 57 taken 580 times.
✓ Branch 58 taken 2271 times.
✓ Branch 59 taken 6617 times.
49664 switch(tempitem.family)
7797 {
7798 case itype_sword:
7799 {
7800 13883 tempitem.flags &= ~(ITEM_FLAG5);
7801 13883 tempitem.misc3 = 0;
7802 13883 tempitem.misc4 = 0;
7803 13883 tempitem.misc5 = 0;
7804 13883 tempitem.misc6 = 0;
7805 13883 tempitem.misc7 = 0;
7806 13883 tempitem.misc8 = 0;
7807 13883 tempitem.misc9 = 0;
7808 13883 tempitem.misc10 = 0;
7809 13883 tempitem.wpn4 = 0;
7810 13883 tempitem.wpn5 = 0;
7811 13883 tempitem.wpn6 = 0;
7812 13883 tempitem.wpn7 = 0;
7813 13883 tempitem.wpn8 = 0;
7814 13883 tempitem.wpn9 = 0;
7815 13883 tempitem.wpn10 = 0;
7816 13883 break;
7817 }
7818 case itype_brang:
7819 {
7820 582 tempitem.flags &= ~(ITEM_FLAG4 | ITEM_FLAG5);
7821 582 tempitem.misc2 = 0;
7822 582 tempitem.misc5 = 0;
7823 582 tempitem.misc6 = 0;
7824 582 tempitem.misc7 = 0;
7825 582 tempitem.misc8 = 0;
7826 582 tempitem.misc9 = 0;
7827 582 tempitem.misc10 = 0;
7828 582 tempitem.wpn4 = 0;
7829 582 tempitem.wpn5 = 0;
7830 582 tempitem.wpn6 = 0;
7831 582 tempitem.wpn7 = 0;
7832 582 tempitem.wpn8 = 0;
7833 582 tempitem.wpn9 = 0;
7834 582 tempitem.wpn10 = 0;
7835 582 break;
7836 }
7837 case itype_arrow:
7838 {
7839 570 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7840 570 tempitem.misc2 = 0;
7841 570 tempitem.misc3 = 0;
7842 570 tempitem.misc4 = 0;
7843 570 tempitem.misc5 = 0;
7844 570 tempitem.misc6 = 0;
7845 570 tempitem.misc7 = 0;
7846 570 tempitem.misc8 = 0;
7847 570 tempitem.misc9 = 0;
7848 570 tempitem.misc10 = 0;
7849 570 tempitem.wpn4 = 0;
7850 570 tempitem.wpn5 = 0;
7851 570 tempitem.wpn6 = 0;
7852 570 tempitem.wpn7 = 0;
7853 570 tempitem.wpn8 = 0;
7854 570 tempitem.wpn9 = 0;
7855 570 tempitem.wpn10 = 0;
7856 570 break;
7857 }
7858 case itype_candle:
7859 {
7860 426 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG5);
7861 426 tempitem.misc1 = 0;
7862 426 tempitem.misc2 = 0;
7863 426 tempitem.misc3 = 0;
7864 426 tempitem.misc4 = 0;
7865 426 tempitem.misc5 = 0;
7866 426 tempitem.misc6 = 0;
7867 426 tempitem.misc7 = 0;
7868 426 tempitem.misc8 = 0;
7869 426 tempitem.misc9 = 0;
7870 426 tempitem.misc10 = 0;
7871 426 tempitem.wpn4 = 0;
7872 426 tempitem.wpn5 = 0;
7873 426 tempitem.wpn6 = 0;
7874 426 tempitem.wpn7 = 0;
7875 426 tempitem.wpn8 = 0;
7876 426 tempitem.wpn9 = 0;
7877 426 tempitem.wpn10 = 0;
7878 426 break;
7879 }
7880 case itype_whistle:
7881 {
7882 240 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7883 240 tempitem.misc3 = 0;
7884 240 tempitem.misc4 = 0;
7885 240 tempitem.misc5 = 0;
7886 240 tempitem.misc6 = 0;
7887 240 tempitem.misc7 = 0;
7888 240 tempitem.misc8 = 0;
7889 240 tempitem.misc9 = 0;
7890 240 tempitem.misc10 = 0;
7891 240 tempitem.wpn2 = 0;
7892 240 tempitem.wpn3 = 0;
7893 240 tempitem.wpn4 = 0;
7894 240 tempitem.wpn5 = 0;
7895 240 tempitem.wpn6 = 0;
7896 240 tempitem.wpn7 = 0;
7897 240 tempitem.wpn8 = 0;
7898 240 tempitem.wpn9 = 0;
7899 240 tempitem.wpn10 = 0;
7900 240 break;
7901 }
7902 case itype_bait:
7903 {
7904 194 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7905 194 tempitem.misc2 = 0;
7906 194 tempitem.misc3 = 0;
7907 194 tempitem.misc4 = 0;
7908 194 tempitem.misc5 = 0;
7909 194 tempitem.misc6 = 0;
7910 194 tempitem.misc7 = 0;
7911 194 tempitem.misc8 = 0;
7912 194 tempitem.misc9 = 0;
7913 194 tempitem.misc10 = 0;
7914 194 tempitem.wpn2 = 0;
7915 194 tempitem.wpn3 = 0;
7916 194 tempitem.wpn4 = 0;
7917 194 tempitem.wpn5 = 0;
7918 194 tempitem.wpn6 = 0;
7919 194 tempitem.wpn7 = 0;
7920 194 tempitem.wpn8 = 0;
7921 194 tempitem.wpn9 = 0;
7922 194 tempitem.wpn10 = 0;
7923 194 break;
7924 }
7925 case itype_letter:
7926 {
7927 384 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7928 384 tempitem.misc1 = 0;
7929 384 tempitem.misc2 = 0;
7930 384 tempitem.misc3 = 0;
7931 384 tempitem.misc4 = 0;
7932 384 tempitem.misc5 = 0;
7933 384 tempitem.misc6 = 0;
7934 384 tempitem.misc7 = 0;
7935 384 tempitem.misc8 = 0;
7936 384 tempitem.misc9 = 0;
7937 384 tempitem.misc10 = 0;
7938 384 tempitem.wpn = 0;
7939 384 tempitem.wpn2 = 0;
7940 384 tempitem.wpn3 = 0;
7941 384 tempitem.wpn4 = 0;
7942 384 tempitem.wpn5 = 0;
7943 384 tempitem.wpn6 = 0;
7944 384 tempitem.wpn7 = 0;
7945 384 tempitem.wpn8 = 0;
7946 384 tempitem.wpn9 = 0;
7947 384 tempitem.wpn10 = 0;
7948 384 break;
7949 }
7950 case itype_potion:
7951 {
7952 407 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7953 407 tempitem.misc3 = 0;
7954 407 tempitem.misc4 = 0;
7955 407 tempitem.misc5 = 0;
7956 407 tempitem.misc6 = 0;
7957 407 tempitem.misc7 = 0;
7958 407 tempitem.misc8 = 0;
7959 407 tempitem.misc9 = 0;
7960 407 tempitem.misc10 = 0;
7961 407 tempitem.wpn = 0;
7962 407 tempitem.wpn2 = 0;
7963 407 tempitem.wpn3 = 0;
7964 407 tempitem.wpn4 = 0;
7965 407 tempitem.wpn5 = 0;
7966 407 tempitem.wpn6 = 0;
7967 407 tempitem.wpn7 = 0;
7968 407 tempitem.wpn8 = 0;
7969 407 tempitem.wpn9 = 0;
7970 407 tempitem.wpn10 = 0;
7971 407 break;
7972 }
7973 case itype_wand:
7974 {
7975 210 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG5);
7976 210 tempitem.misc1 = 0;
7977 210 tempitem.misc2 = 0;
7978 210 tempitem.misc3 = 0;
7979 210 tempitem.misc4 = 0;
7980 210 tempitem.misc5 = 0;
7981 210 tempitem.misc6 = 0;
7982 210 tempitem.misc7 = 0;
7983 210 tempitem.misc8 = 0;
7984 210 tempitem.misc9 = 0;
7985 210 tempitem.misc10 = 0;
7986 210 tempitem.wpn4 = 0;
7987 210 tempitem.wpn5 = 0;
7988 210 tempitem.wpn6 = 0;
7989 210 tempitem.wpn7 = 0;
7990 210 tempitem.wpn8 = 0;
7991 210 tempitem.wpn9 = 0;
7992 210 tempitem.wpn10 = 0;
7993 210 break;
7994 }
7995 case itype_ring:
7996 {
7997 630 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7998 630 tempitem.misc2 = 0;
7999 630 tempitem.misc3 = 0;
8000 630 tempitem.misc4 = 0;
8001 630 tempitem.misc5 = 0;
8002 630 tempitem.misc6 = 0;
8003 630 tempitem.misc7 = 0;
8004 630 tempitem.misc8 = 0;
8005 630 tempitem.misc9 = 0;
8006 630 tempitem.misc10 = 0;
8007 630 tempitem.wpn = 0;
8008 630 tempitem.wpn2 = 0;
8009 630 tempitem.wpn3 = 0;
8010 630 tempitem.wpn4 = 0;
8011 630 tempitem.wpn5 = 0;
8012 630 tempitem.wpn6 = 0;
8013 630 tempitem.wpn7 = 0;
8014 630 tempitem.wpn8 = 0;
8015 630 tempitem.wpn9 = 0;
8016 630 tempitem.wpn10 = 0;
8017 630 break;
8018 }
8019 case itype_wallet:
8020 {
8021 598 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8022 598 tempitem.misc3 = 0;
8023 598 tempitem.misc4 = 0;
8024 598 tempitem.misc5 = 0;
8025 598 tempitem.misc6 = 0;
8026 598 tempitem.misc7 = 0;
8027 598 tempitem.misc8 = 0;
8028 598 tempitem.misc9 = 0;
8029 598 tempitem.misc10 = 0;
8030 598 tempitem.wpn = 0;
8031 598 tempitem.wpn2 = 0;
8032 598 tempitem.wpn3 = 0;
8033 598 tempitem.wpn4 = 0;
8034 598 tempitem.wpn5 = 0;
8035 598 tempitem.wpn6 = 0;
8036 598 tempitem.wpn7 = 0;
8037 598 tempitem.wpn8 = 0;
8038 598 tempitem.wpn9 = 0;
8039 598 tempitem.wpn10 = 0;
8040 598 break;
8041 }
8042 case itype_amulet:
8043 {
8044 380 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8045 380 tempitem.misc1 = 0;
8046 380 tempitem.misc2 = 0;
8047 380 tempitem.misc3 = 0;
8048 380 tempitem.misc4 = 0;
8049 380 tempitem.misc5 = 0;
8050 380 tempitem.misc6 = 0;
8051 380 tempitem.misc7 = 0;
8052 380 tempitem.misc8 = 0;
8053 380 tempitem.misc9 = 0;
8054 380 tempitem.misc10 = 0;
8055 380 tempitem.wpn = 0;
8056 380 tempitem.wpn2 = 0;
8057 380 tempitem.wpn3 = 0;
8058 380 tempitem.wpn4 = 0;
8059 380 tempitem.wpn5 = 0;
8060 380 tempitem.wpn6 = 0;
8061 380 tempitem.wpn7 = 0;
8062 380 tempitem.wpn8 = 0;
8063 380 tempitem.wpn9 = 0;
8064 380 tempitem.wpn10 = 0;
8065 380 break;
8066 }
8067 case itype_shield:
8068 {
8069 590 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8070 590 tempitem.misc3 = 0;
8071 590 tempitem.misc4 = 0;
8072 590 tempitem.misc5 = 0;
8073 590 tempitem.misc6 = 0;
8074 590 tempitem.misc7 = 0;
8075 590 tempitem.misc8 = 0;
8076 590 tempitem.misc9 = 0;
8077 590 tempitem.misc10 = 0;
8078 590 tempitem.wpn = 0;
8079 590 tempitem.wpn2 = 0;
8080 590 tempitem.wpn3 = 0;
8081 590 tempitem.wpn4 = 0;
8082 590 tempitem.wpn5 = 0;
8083 590 tempitem.wpn6 = 0;
8084 590 tempitem.wpn7 = 0;
8085 590 tempitem.wpn8 = 0;
8086 590 tempitem.wpn9 = 0;
8087 590 tempitem.wpn10 = 0;
8088 590 break;
8089 }
8090 case itype_bow:
8091 {
8092 384 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8093 384 tempitem.misc1 = 0;
8094 384 tempitem.misc2 = 0;
8095 384 tempitem.misc3 = 0;
8096 384 tempitem.misc4 = 0;
8097 384 tempitem.misc5 = 0;
8098 384 tempitem.misc6 = 0;
8099 384 tempitem.misc7 = 0;
8100 384 tempitem.misc8 = 0;
8101 384 tempitem.misc9 = 0;
8102 384 tempitem.misc10 = 0;
8103 384 tempitem.wpn = 0;
8104 384 tempitem.wpn2 = 0;
8105 384 tempitem.wpn3 = 0;
8106 384 tempitem.wpn4 = 0;
8107 384 tempitem.wpn5 = 0;
8108 384 tempitem.wpn6 = 0;
8109 384 tempitem.wpn7 = 0;
8110 384 tempitem.wpn8 = 0;
8111 384 tempitem.wpn9 = 0;
8112 384 tempitem.wpn10 = 0;
8113 384 break;
8114 }
8115 case itype_raft:
8116 {
8117 192 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8118 192 tempitem.misc1 = 0;
8119 192 tempitem.misc2 = 0;
8120 192 tempitem.misc3 = 0;
8121 192 tempitem.misc4 = 0;
8122 192 tempitem.misc5 = 0;
8123 192 tempitem.misc6 = 0;
8124 192 tempitem.misc7 = 0;
8125 192 tempitem.misc8 = 0;
8126 192 tempitem.misc9 = 0;
8127 192 tempitem.misc10 = 0;
8128 192 tempitem.wpn = 0;
8129 192 tempitem.wpn2 = 0;
8130 192 tempitem.wpn3 = 0;
8131 192 tempitem.wpn4 = 0;
8132 192 tempitem.wpn5 = 0;
8133 192 tempitem.wpn6 = 0;
8134 192 tempitem.wpn7 = 0;
8135 192 tempitem.wpn8 = 0;
8136 192 tempitem.wpn9 = 0;
8137 192 tempitem.wpn10 = 0;
8138 192 break;
8139 }
8140 case itype_ladder:
8141 {
8142 384 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8143 384 tempitem.misc1 = 0;
8144 384 tempitem.misc2 = 0;
8145 384 tempitem.misc3 = 0;
8146 384 tempitem.misc4 = 0;
8147 384 tempitem.misc5 = 0;
8148 384 tempitem.misc6 = 0;
8149 384 tempitem.misc7 = 0;
8150 384 tempitem.misc8 = 0;
8151 384 tempitem.misc9 = 0;
8152 384 tempitem.misc10 = 0;
8153 384 tempitem.wpn = 0;
8154 384 tempitem.wpn2 = 0;
8155 384 tempitem.wpn3 = 0;
8156 384 tempitem.wpn4 = 0;
8157 384 tempitem.wpn5 = 0;
8158 384 tempitem.wpn6 = 0;
8159 384 tempitem.wpn7 = 0;
8160 384 tempitem.wpn8 = 0;
8161 384 tempitem.wpn9 = 0;
8162 384 tempitem.wpn10 = 0;
8163 384 break;
8164 }
8165 case itype_book:
8166 {
8167 208 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8168 208 tempitem.misc1 = 0;
8169 208 tempitem.misc2 = 0;
8170 208 tempitem.misc3 = 0;
8171 208 tempitem.misc4 = 0;
8172 208 tempitem.misc5 = 0;
8173 208 tempitem.misc6 = 0;
8174 208 tempitem.misc7 = 0;
8175 208 tempitem.misc8 = 0;
8176 208 tempitem.misc9 = 0;
8177 208 tempitem.misc10 = 0;
8178 208 tempitem.wpn3 = 0;
8179 208 tempitem.wpn4 = 0;
8180 208 tempitem.wpn5 = 0;
8181 208 tempitem.wpn6 = 0;
8182 208 tempitem.wpn7 = 0;
8183 208 tempitem.wpn8 = 0;
8184 208 tempitem.wpn9 = 0;
8185 208 tempitem.wpn10 = 0;
8186 208 break;
8187 }
8188 case itype_magickey:
8189 {
8190 192 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8191 192 tempitem.misc1 = 0;
8192 192 tempitem.misc2 = 0;
8193 192 tempitem.misc3 = 0;
8194 192 tempitem.misc4 = 0;
8195 192 tempitem.misc5 = 0;
8196 192 tempitem.misc6 = 0;
8197 192 tempitem.misc7 = 0;
8198 192 tempitem.misc8 = 0;
8199 192 tempitem.misc9 = 0;
8200 192 tempitem.misc10 = 0;
8201 192 tempitem.wpn = 0;
8202 192 tempitem.wpn2 = 0;
8203 192 tempitem.wpn3 = 0;
8204 192 tempitem.wpn4 = 0;
8205 192 tempitem.wpn5 = 0;
8206 192 tempitem.wpn6 = 0;
8207 192 tempitem.wpn7 = 0;
8208 192 tempitem.wpn8 = 0;
8209 192 tempitem.wpn9 = 0;
8210 192 tempitem.wpn10 = 0;
8211 192 break;
8212 }
8213 case itype_bracelet:
8214 {
8215 582 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8216 582 tempitem.misc1 = 0;
8217 582 tempitem.misc2 = 0;
8218 582 tempitem.misc3 = 0;
8219 582 tempitem.misc4 = 0;
8220 582 tempitem.misc5 = 0;
8221 582 tempitem.misc6 = 0;
8222 582 tempitem.misc7 = 0;
8223 582 tempitem.misc8 = 0;
8224 582 tempitem.misc9 = 0;
8225 582 tempitem.misc10 = 0;
8226 582 tempitem.wpn = 0;
8227 582 tempitem.wpn2 = 0;
8228 582 tempitem.wpn3 = 0;
8229 582 tempitem.wpn4 = 0;
8230 582 tempitem.wpn5 = 0;
8231 582 tempitem.wpn6 = 0;
8232 582 tempitem.wpn7 = 0;
8233 582 tempitem.wpn8 = 0;
8234 582 tempitem.wpn9 = 0;
8235 582 tempitem.wpn10 = 0;
8236 582 break;
8237 }
8238 case itype_flippers:
8239 {
8240 194 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8241 194 tempitem.misc1 = 0;
8242 194 tempitem.misc2 = 0;
8243 194 tempitem.misc3 = 0;
8244 194 tempitem.misc4 = 0;
8245 194 tempitem.misc5 = 0;
8246 194 tempitem.misc6 = 0;
8247 194 tempitem.misc7 = 0;
8248 194 tempitem.misc8 = 0;
8249 194 tempitem.misc9 = 0;
8250 194 tempitem.misc10 = 0;
8251 194 tempitem.wpn = 0;
8252 194 tempitem.wpn2 = 0;
8253 194 tempitem.wpn3 = 0;
8254 194 tempitem.wpn4 = 0;
8255 194 tempitem.wpn5 = 0;
8256 194 tempitem.wpn6 = 0;
8257 194 tempitem.wpn7 = 0;
8258 194 tempitem.wpn8 = 0;
8259 194 tempitem.wpn9 = 0;
8260 194 tempitem.wpn10 = 0;
8261 194 break;
8262 }
8263 case itype_boots:
8264 {
8265 196 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8266 196 tempitem.misc1 = 0;
8267 196 tempitem.misc2 = 0;
8268 196 tempitem.misc3 = 0;
8269 196 tempitem.misc4 = 0;
8270 196 tempitem.misc5 = 0;
8271 196 tempitem.misc6 = 0;
8272 196 tempitem.misc7 = 0;
8273 196 tempitem.misc8 = 0;
8274 196 tempitem.misc9 = 0;
8275 196 tempitem.misc10 = 0;
8276 196 tempitem.wpn = 0;
8277 196 tempitem.wpn2 = 0;
8278 196 tempitem.wpn3 = 0;
8279 196 tempitem.wpn4 = 0;
8280 196 tempitem.wpn5 = 0;
8281 196 tempitem.wpn6 = 0;
8282 196 tempitem.wpn7 = 0;
8283 196 tempitem.wpn8 = 0;
8284 196 tempitem.wpn9 = 0;
8285 196 tempitem.wpn10 = 0;
8286 196 break;
8287 }
8288 case itype_hookshot:
8289 {
8290 386 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8291 386 tempitem.misc5 = 0;
8292 386 tempitem.misc6 = 0;
8293 386 tempitem.misc7 = 0;
8294 386 tempitem.misc8 = 0;
8295 386 tempitem.misc9 = 0;
8296 386 tempitem.misc10 = 0;
8297 386 tempitem.wpn5 = 0;
8298 386 tempitem.wpn6 = 0;
8299 386 tempitem.wpn7 = 0;
8300 386 tempitem.wpn8 = 0;
8301 386 tempitem.wpn9 = 0;
8302 386 tempitem.wpn10 = 0;
8303 386 break;
8304 }
8305 case itype_lens:
8306 {
8307 186 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8308 186 tempitem.misc2 = 0;
8309 186 tempitem.misc3 = 0;
8310 186 tempitem.misc4 = 0;
8311 186 tempitem.misc5 = 0;
8312 186 tempitem.misc6 = 0;
8313 186 tempitem.misc7 = 0;
8314 186 tempitem.misc8 = 0;
8315 186 tempitem.misc9 = 0;
8316 186 tempitem.misc10 = 0;
8317 186 tempitem.wpn = 0;
8318 186 tempitem.wpn2 = 0;
8319 186 tempitem.wpn3 = 0;
8320 186 tempitem.wpn4 = 0;
8321 186 tempitem.wpn5 = 0;
8322 186 tempitem.wpn6 = 0;
8323 186 tempitem.wpn7 = 0;
8324 186 tempitem.wpn8 = 0;
8325 186 tempitem.wpn9 = 0;
8326 186 tempitem.wpn10 = 0;
8327 186 break;
8328 }
8329 case itype_hammer:
8330 {
8331 194 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8332 194 tempitem.misc1 = 0;
8333 194 tempitem.misc2 = 0;
8334 194 tempitem.misc3 = 0;
8335 194 tempitem.misc4 = 0;
8336 194 tempitem.misc5 = 0;
8337 194 tempitem.misc6 = 0;
8338 194 tempitem.misc7 = 0;
8339 194 tempitem.misc8 = 0;
8340 194 tempitem.misc9 = 0;
8341 194 tempitem.misc10 = 0;
8342 194 tempitem.wpn3 = 0;
8343 194 tempitem.wpn4 = 0;
8344 194 tempitem.wpn5 = 0;
8345 194 tempitem.wpn6 = 0;
8346 194 tempitem.wpn7 = 0;
8347 194 tempitem.wpn8 = 0;
8348 194 tempitem.wpn9 = 0;
8349 194 tempitem.wpn10 = 0;
8350 194 break;
8351 }
8352 case itype_divinefire:
8353 {
8354 192 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG4 | ITEM_FLAG5);
8355 192 tempitem.misc3 = 0;
8356 192 tempitem.misc4 = 0;
8357 192 tempitem.misc5 = 0;
8358 192 tempitem.misc6 = 0;
8359 192 tempitem.misc7 = 0;
8360 192 tempitem.misc8 = 0;
8361 192 tempitem.misc9 = 0;
8362 192 tempitem.misc10 = 0;
8363 192 tempitem.wpn6 = 0;
8364 192 tempitem.wpn7 = 0;
8365 192 tempitem.wpn8 = 0;
8366 192 tempitem.wpn9 = 0;
8367 192 tempitem.wpn10 = 0;
8368 192 break;
8369 }
8370 case itype_divineescape:
8371 {
8372 192 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8373 192 tempitem.misc2 = 0;
8374 192 tempitem.misc3 = 0;
8375 192 tempitem.misc4 = 0;
8376 192 tempitem.misc5 = 0;
8377 192 tempitem.misc6 = 0;
8378 192 tempitem.misc7 = 0;
8379 192 tempitem.misc8 = 0;
8380 192 tempitem.misc9 = 0;
8381 192 tempitem.misc10 = 0;
8382 192 tempitem.wpn = 0;
8383 192 tempitem.wpn2 = 0;
8384 192 tempitem.wpn3 = 0;
8385 192 tempitem.wpn4 = 0;
8386 192 tempitem.wpn5 = 0;
8387 192 tempitem.wpn6 = 0;
8388 192 tempitem.wpn7 = 0;
8389 192 tempitem.wpn8 = 0;
8390 192 tempitem.wpn9 = 0;
8391 192 tempitem.wpn10 = 0;
8392 192 break;
8393 }
8394 case itype_divineprotection:
8395 {
8396 192 tempitem.flags &= ~ (ITEM_FLAG5);
8397 192 tempitem.misc2 = 0;
8398 192 tempitem.misc3 = 0;
8399 192 tempitem.misc4 = 0;
8400 192 tempitem.misc5 = 0;
8401 192 tempitem.misc6 = 0;
8402 192 tempitem.misc7 = 0;
8403 192 tempitem.misc8 = 0;
8404 192 tempitem.misc9 = 0;
8405 192 tempitem.misc10 = 0;
8406 192 break;
8407 }
8408 case itype_bomb:
8409 {
8410 208 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8411 208 tempitem.misc4 = 0;
8412 208 tempitem.misc5 = 0;
8413 208 tempitem.misc6 = 0;
8414 208 tempitem.misc7 = 0;
8415 208 tempitem.misc8 = 0;
8416 208 tempitem.misc9 = 0;
8417 208 tempitem.misc10 = 0;
8418 208 tempitem.wpn3 = 0;
8419 208 tempitem.wpn4 = 0;
8420 208 tempitem.wpn5 = 0;
8421 208 tempitem.wpn6 = 0;
8422 208 tempitem.wpn7 = 0;
8423 208 tempitem.wpn8 = 0;
8424 208 tempitem.wpn9 = 0;
8425 208 tempitem.wpn10 = 0;
8426 208 break;
8427 }
8428 case itype_sbomb:
8429 {
8430 194 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8431 194 tempitem.misc4 = 0;
8432 194 tempitem.misc5 = 0;
8433 194 tempitem.misc6 = 0;
8434 194 tempitem.misc7 = 0;
8435 194 tempitem.misc8 = 0;
8436 194 tempitem.misc9 = 0;
8437 194 tempitem.misc10 = 0;
8438 194 tempitem.wpn3 = 0;
8439 194 tempitem.wpn4 = 0;
8440 194 tempitem.wpn5 = 0;
8441 194 tempitem.wpn6 = 0;
8442 194 tempitem.wpn7 = 0;
8443 194 tempitem.wpn8 = 0;
8444 194 tempitem.wpn9 = 0;
8445 194 tempitem.wpn10 = 0;
8446 194 break;
8447 }
8448 case itype_clock:
8449 {
8450 194 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8451 194 tempitem.misc2 = 0;
8452 194 tempitem.misc3 = 0;
8453 194 tempitem.misc4 = 0;
8454 194 tempitem.misc5 = 0;
8455 194 tempitem.misc6 = 0;
8456 194 tempitem.misc7 = 0;
8457 194 tempitem.misc8 = 0;
8458 194 tempitem.misc9 = 0;
8459 194 tempitem.misc10 = 0;
8460 194 tempitem.wpn = 0;
8461 194 tempitem.wpn2 = 0;
8462 194 tempitem.wpn3 = 0;
8463 194 tempitem.wpn4 = 0;
8464 194 tempitem.wpn5 = 0;
8465 194 tempitem.wpn6 = 0;
8466 194 tempitem.wpn7 = 0;
8467 194 tempitem.wpn8 = 0;
8468 194 tempitem.wpn9 = 0;
8469 194 tempitem.wpn10 = 0;
8470 194 break;
8471 }
8472 case itype_key:
8473 {
8474 192 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8475 192 tempitem.misc1 = 0;
8476 192 tempitem.misc2 = 0;
8477 192 tempitem.misc3 = 0;
8478 192 tempitem.misc4 = 0;
8479 192 tempitem.misc5 = 0;
8480 192 tempitem.misc6 = 0;
8481 192 tempitem.misc7 = 0;
8482 192 tempitem.misc8 = 0;
8483 192 tempitem.misc9 = 0;
8484 192 tempitem.misc10 = 0;
8485 192 tempitem.wpn = 0;
8486 192 tempitem.wpn2 = 0;
8487 192 tempitem.wpn3 = 0;
8488 192 tempitem.wpn4 = 0;
8489 192 tempitem.wpn5 = 0;
8490 192 tempitem.wpn6 = 0;
8491 192 tempitem.wpn7 = 0;
8492 192 tempitem.wpn8 = 0;
8493 192 tempitem.wpn9 = 0;
8494 192 tempitem.wpn10 = 0;
8495 192 break;
8496 }
8497 case itype_magiccontainer:
8498 {
8499 196 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8500 196 tempitem.misc1 = 0;
8501 196 tempitem.misc2 = 0;
8502 196 tempitem.misc3 = 0;
8503 196 tempitem.misc4 = 0;
8504 196 tempitem.misc5 = 0;
8505 196 tempitem.misc6 = 0;
8506 196 tempitem.misc7 = 0;
8507 196 tempitem.misc8 = 0;
8508 196 tempitem.misc9 = 0;
8509 196 tempitem.misc10 = 0;
8510 196 tempitem.wpn = 0;
8511 196 tempitem.wpn2 = 0;
8512 196 tempitem.wpn3 = 0;
8513 196 tempitem.wpn4 = 0;
8514 196 tempitem.wpn5 = 0;
8515 196 tempitem.wpn6 = 0;
8516 196 tempitem.wpn7 = 0;
8517 196 tempitem.wpn8 = 0;
8518 196 tempitem.wpn9 = 0;
8519 196 tempitem.wpn10 = 0;
8520 196 break;
8521 }
8522 case itype_triforcepiece:
8523 {
8524 384 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8525 384 tempitem.misc3 = 0;
8526 384 tempitem.misc4 = 0;
8527 384 tempitem.misc5 = 0;
8528 384 tempitem.misc6 = 0;
8529 384 tempitem.misc7 = 0;
8530 384 tempitem.misc8 = 0;
8531 384 tempitem.misc9 = 0;
8532 384 tempitem.misc10 = 0;
8533 384 tempitem.wpn = 0;
8534 384 tempitem.wpn2 = 0;
8535 384 tempitem.wpn3 = 0;
8536 384 tempitem.wpn4 = 0;
8537 384 tempitem.wpn5 = 0;
8538 384 tempitem.wpn6 = 0;
8539 384 tempitem.wpn7 = 0;
8540 384 tempitem.wpn8 = 0;
8541 384 tempitem.wpn9 = 0;
8542 384 tempitem.wpn10 = 0;
8543 384 break;
8544 }
8545 case itype_map: case itype_compass: case itype_bosskey:
8546 {
8547 580 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8548 580 tempitem.misc1 = 0;
8549 580 tempitem.misc2 = 0;
8550 580 tempitem.misc3 = 0;
8551 580 tempitem.misc4 = 0;
8552 580 tempitem.misc5 = 0;
8553 580 tempitem.misc6 = 0;
8554 580 tempitem.misc7 = 0;
8555 580 tempitem.misc8 = 0;
8556 580 tempitem.misc9 = 0;
8557 580 tempitem.misc10 = 0;
8558 580 tempitem.wpn = 0;
8559 580 tempitem.wpn2 = 0;
8560 580 tempitem.wpn3 = 0;
8561 580 tempitem.wpn4 = 0;
8562 580 tempitem.wpn5 = 0;
8563 580 tempitem.wpn6 = 0;
8564 580 tempitem.wpn7 = 0;
8565 580 tempitem.wpn8 = 0;
8566 580 tempitem.wpn9 = 0;
8567 580 tempitem.wpn10 = 0;
8568 580 break;
8569 }
8570 case itype_quiver:
8571 {
8572 768 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8573 768 tempitem.misc3 = 0;
8574 768 tempitem.misc4 = 0;
8575 768 tempitem.misc5 = 0;
8576 768 tempitem.misc6 = 0;
8577 768 tempitem.misc7 = 0;
8578 768 tempitem.misc8 = 0;
8579 768 tempitem.misc9 = 0;
8580 768 tempitem.misc10 = 0;
8581 768 tempitem.wpn = 0;
8582 768 tempitem.wpn2 = 0;
8583 768 tempitem.wpn3 = 0;
8584 768 tempitem.wpn4 = 0;
8585 768 tempitem.wpn5 = 0;
8586 768 tempitem.wpn6 = 0;
8587 768 tempitem.wpn7 = 0;
8588 768 tempitem.wpn8 = 0;
8589 768 tempitem.wpn9 = 0;
8590 768 tempitem.wpn10 = 0;
8591 768 break;
8592 }
8593 case itype_lkey:
8594 {
8595 394 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8596 394 tempitem.misc1 = 0;
8597 394 tempitem.misc2 = 0;
8598 394 tempitem.misc3 = 0;
8599 394 tempitem.misc4 = 0;
8600 394 tempitem.misc5 = 0;
8601 394 tempitem.misc6 = 0;
8602 394 tempitem.misc7 = 0;
8603 394 tempitem.misc8 = 0;
8604 394 tempitem.misc9 = 0;
8605 394 tempitem.misc10 = 0;
8606 394 tempitem.wpn = 0;
8607 394 tempitem.wpn2 = 0;
8608 394 tempitem.wpn3 = 0;
8609 394 tempitem.wpn4 = 0;
8610 394 tempitem.wpn5 = 0;
8611 394 tempitem.wpn6 = 0;
8612 394 tempitem.wpn7 = 0;
8613 394 tempitem.wpn8 = 0;
8614 394 tempitem.wpn9 = 0;
8615 394 tempitem.wpn10 = 0;
8616 394 break;
8617 }
8618 case itype_cbyrna:
8619 {
8620 192 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG5);
8621 192 tempitem.misc4 = 0;
8622 192 tempitem.misc5 = 0;
8623 192 tempitem.misc6 = 0;
8624 192 tempitem.misc7 = 0;
8625 192 tempitem.misc8 = 0;
8626 192 tempitem.misc9 = 0;
8627 192 tempitem.misc10 = 0;
8628 192 tempitem.wpn6 = 0;
8629 192 tempitem.wpn7 = 0;
8630 192 tempitem.wpn8 = 0;
8631 192 tempitem.wpn9 = 0;
8632 192 tempitem.wpn10 = 0;
8633 192 break;
8634 }
8635 case itype_rupee: case itype_arrowammo:
8636 {
8637 2271 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8638 2271 tempitem.misc1 = 0;
8639 2271 tempitem.misc2 = 0;
8640 2271 tempitem.misc3 = 0;
8641 2271 tempitem.misc4 = 0;
8642 2271 tempitem.misc5 = 0;
8643 2271 tempitem.misc6 = 0;
8644 2271 tempitem.misc7 = 0;
8645 2271 tempitem.misc8 = 0;
8646 2271 tempitem.misc9 = 0;
8647 2271 tempitem.misc10 = 0;
8648 2271 tempitem.wpn = 0;
8649 2271 tempitem.wpn2 = 0;
8650 2271 tempitem.wpn3 = 0;
8651 2271 tempitem.wpn4 = 0;
8652 2271 tempitem.wpn5 = 0;
8653 2271 tempitem.wpn6 = 0;
8654 2271 tempitem.wpn7 = 0;
8655 2271 tempitem.wpn8 = 0;
8656 2271 tempitem.wpn9 = 0;
8657 2271 tempitem.wpn10 = 0;
8658 2271 break;
8659 }
8660 case itype_fairy:
8661 {
8662 369 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8663 369 tempitem.misc4 = 0;
8664 369 tempitem.misc5 = 0;
8665 369 tempitem.misc6 = 0;
8666 369 tempitem.misc7 = 0;
8667 369 tempitem.misc8 = 0;
8668 369 tempitem.misc9 = 0;
8669 369 tempitem.misc10 = 0;
8670 369 tempitem.wpn = 0;
8671 369 tempitem.wpn2 = 0;
8672 369 tempitem.wpn3 = 0;
8673 369 tempitem.wpn4 = 0;
8674 369 tempitem.wpn5 = 0;
8675 369 tempitem.wpn6 = 0;
8676 369 tempitem.wpn7 = 0;
8677 369 tempitem.wpn8 = 0;
8678 369 tempitem.wpn9 = 0;
8679 369 tempitem.wpn10 = 0;
8680 369 break;
8681 }
8682 case itype_magic: case itype_heart: case itype_heartcontainer: case itype_heartpiece: case itype_killem: case itype_bombammo:
8683 {
8684 1996 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8685 1996 tempitem.misc1 = 0;
8686 1996 tempitem.misc2 = 0;
8687 1996 tempitem.misc3 = 0;
8688 1996 tempitem.misc4 = 0;
8689 1996 tempitem.misc5 = 0;
8690 1996 tempitem.misc6 = 0;
8691 1996 tempitem.misc7 = 0;
8692 1996 tempitem.misc8 = 0;
8693 1996 tempitem.misc9 = 0;
8694 1996 tempitem.misc10 = 0;
8695 1996 tempitem.wpn = 0;
8696 1996 tempitem.wpn2 = 0;
8697 1996 tempitem.wpn3 = 0;
8698 1996 tempitem.wpn4 = 0;
8699 1996 tempitem.wpn5 = 0;
8700 1996 tempitem.wpn6 = 0;
8701 1996 tempitem.wpn7 = 0;
8702 1996 tempitem.wpn8 = 0;
8703 1996 tempitem.wpn9 = 0;
8704 1996 tempitem.wpn10 = 0;
8705 1996 break;
8706 }
8707 case itype_bombbag:
8708 {
8709 768 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8710 768 tempitem.misc3 = 0;
8711 768 tempitem.misc4 = 0;
8712 768 tempitem.misc5 = 0;
8713 768 tempitem.misc6 = 0;
8714 768 tempitem.misc7 = 0;
8715 768 tempitem.misc8 = 0;
8716 768 tempitem.misc9 = 0;
8717 768 tempitem.misc10 = 0;
8718 768 tempitem.wpn = 0;
8719 768 tempitem.wpn2 = 0;
8720 768 tempitem.wpn3 = 0;
8721 768 tempitem.wpn4 = 0;
8722 768 tempitem.wpn5 = 0;
8723 768 tempitem.wpn6 = 0;
8724 768 tempitem.wpn7 = 0;
8725 768 tempitem.wpn8 = 0;
8726 768 tempitem.wpn9 = 0;
8727 768 tempitem.wpn10 = 0;
8728 768 break;
8729 }
8730 case itype_rocs:
8731 {
8732 192 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8733 192 tempitem.misc1 = 0;
8734 192 tempitem.misc2 = 0;
8735 192 tempitem.misc3 = 0;
8736 192 tempitem.misc4 = 0;
8737 192 tempitem.misc5 = 0;
8738 192 tempitem.misc6 = 0;
8739 192 tempitem.misc7 = 0;
8740 192 tempitem.misc8 = 0;
8741 192 tempitem.misc9 = 0;
8742 192 tempitem.misc10 = 0;
8743 192 tempitem.wpn = 0;
8744 192 tempitem.wpn2 = 0;
8745 192 tempitem.wpn3 = 0;
8746 192 tempitem.wpn4 = 0;
8747 192 tempitem.wpn5 = 0;
8748 192 tempitem.wpn6 = 0;
8749 192 tempitem.wpn7 = 0;
8750 192 tempitem.wpn8 = 0;
8751 192 tempitem.wpn9 = 0;
8752 192 tempitem.wpn10 = 0;
8753 192 break;
8754 }
8755 case itype_hoverboots:
8756 {
8757 192 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8758 192 tempitem.misc2 = 0;
8759 192 tempitem.misc3 = 0;
8760 192 tempitem.misc4 = 0;
8761 192 tempitem.misc5 = 0;
8762 192 tempitem.misc6 = 0;
8763 192 tempitem.misc7 = 0;
8764 192 tempitem.misc8 = 0;
8765 192 tempitem.misc9 = 0;
8766 192 tempitem.misc10 = 0;
8767 192 tempitem.wpn2 = 0;
8768 192 tempitem.wpn3 = 0;
8769 192 tempitem.wpn4 = 0;
8770 192 tempitem.wpn5 = 0;
8771 192 tempitem.wpn6 = 0;
8772 192 tempitem.wpn7 = 0;
8773 192 tempitem.wpn8 = 0;
8774 192 tempitem.wpn9 = 0;
8775 192 tempitem.wpn10 = 0;
8776 192 break;
8777 }
8778 case itype_spinscroll:
8779 {
8780 192 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8781 192 tempitem.misc2 = 0;
8782 192 tempitem.misc3 = 0;
8783 192 tempitem.misc4 = 0;
8784 192 tempitem.misc5 = 0;
8785 192 tempitem.misc6 = 0;
8786 192 tempitem.misc7 = 0;
8787 192 tempitem.misc8 = 0;
8788 192 tempitem.misc9 = 0;
8789 192 tempitem.misc10 = 0;
8790 192 tempitem.wpn = 0;
8791 192 tempitem.wpn2 = 0;
8792 192 tempitem.wpn3 = 0;
8793 192 tempitem.wpn4 = 0;
8794 192 tempitem.wpn5 = 0;
8795 192 tempitem.wpn6 = 0;
8796 192 tempitem.wpn7 = 0;
8797 192 tempitem.wpn8 = 0;
8798 192 tempitem.wpn9 = 0;
8799 192 tempitem.wpn10 = 0;
8800 192 break;
8801 }
8802 case itype_crossscroll:
8803 {
8804 192 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8805 192 tempitem.misc1 = 0;
8806 192 tempitem.misc2 = 0;
8807 192 tempitem.misc3 = 0;
8808 192 tempitem.misc4 = 0;
8809 192 tempitem.misc5 = 0;
8810 192 tempitem.misc6 = 0;
8811 192 tempitem.misc7 = 0;
8812 192 tempitem.misc8 = 0;
8813 192 tempitem.misc9 = 0;
8814 192 tempitem.misc10 = 0;
8815 192 tempitem.wpn = 0;
8816 192 tempitem.wpn2 = 0;
8817 192 tempitem.wpn3 = 0;
8818 192 tempitem.wpn4 = 0;
8819 192 tempitem.wpn5 = 0;
8820 192 tempitem.wpn6 = 0;
8821 192 tempitem.wpn7 = 0;
8822 192 tempitem.wpn8 = 0;
8823 192 tempitem.wpn9 = 0;
8824 192 tempitem.wpn10 = 0;
8825 192 break;
8826 }
8827 case itype_quakescroll:
8828 {
8829 192 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8830 192 tempitem.misc3 = 0;
8831 192 tempitem.misc4 = 0;
8832 192 tempitem.misc5 = 0;
8833 192 tempitem.misc6 = 0;
8834 192 tempitem.misc7 = 0;
8835 192 tempitem.misc8 = 0;
8836 192 tempitem.misc9 = 0;
8837 192 tempitem.misc10 = 0;
8838 192 tempitem.wpn = 0;
8839 192 tempitem.wpn2 = 0;
8840 192 tempitem.wpn3 = 0;
8841 192 tempitem.wpn4 = 0;
8842 192 tempitem.wpn5 = 0;
8843 192 tempitem.wpn6 = 0;
8844 192 tempitem.wpn7 = 0;
8845 192 tempitem.wpn8 = 0;
8846 192 tempitem.wpn9 = 0;
8847 192 tempitem.wpn10 = 0;
8848 192 break;
8849 }
8850 case itype_whispring:
8851 {
8852 386 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8853 386 tempitem.misc2 = 0;
8854 386 tempitem.misc3 = 0;
8855 386 tempitem.misc4 = 0;
8856 386 tempitem.misc5 = 0;
8857 386 tempitem.misc6 = 0;
8858 386 tempitem.misc7 = 0;
8859 386 tempitem.misc8 = 0;
8860 386 tempitem.misc9 = 0;
8861 386 tempitem.misc10 = 0;
8862 386 tempitem.wpn = 0;
8863 386 tempitem.wpn2 = 0;
8864 386 tempitem.wpn3 = 0;
8865 386 tempitem.wpn4 = 0;
8866 386 tempitem.wpn5 = 0;
8867 386 tempitem.wpn6 = 0;
8868 386 tempitem.wpn7 = 0;
8869 386 tempitem.wpn8 = 0;
8870 386 tempitem.wpn9 = 0;
8871 386 tempitem.wpn10 = 0;
8872 386 break;
8873 }
8874 case itype_chargering:
8875 {
8876 384 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8877 384 tempitem.misc3 = 0;
8878 384 tempitem.misc4 = 0;
8879 384 tempitem.misc5 = 0;
8880 384 tempitem.misc6 = 0;
8881 384 tempitem.misc7 = 0;
8882 384 tempitem.misc8 = 0;
8883 384 tempitem.misc9 = 0;
8884 384 tempitem.misc10 = 0;
8885 384 tempitem.wpn = 0;
8886 384 tempitem.wpn2 = 0;
8887 384 tempitem.wpn3 = 0;
8888 384 tempitem.wpn4 = 0;
8889 384 tempitem.wpn5 = 0;
8890 384 tempitem.wpn6 = 0;
8891 384 tempitem.wpn7 = 0;
8892 384 tempitem.wpn8 = 0;
8893 384 tempitem.wpn9 = 0;
8894 384 tempitem.wpn10 = 0;
8895 384 break;
8896 }
8897 case itype_perilscroll:
8898 {
8899 192 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8900 192 tempitem.misc2 = 0;
8901 192 tempitem.misc3 = 0;
8902 192 tempitem.misc4 = 0;
8903 192 tempitem.misc5 = 0;
8904 192 tempitem.misc6 = 0;
8905 192 tempitem.misc7 = 0;
8906 192 tempitem.misc8 = 0;
8907 192 tempitem.misc9 = 0;
8908 192 tempitem.misc10 = 0;
8909 192 tempitem.wpn = 0;
8910 192 tempitem.wpn2 = 0;
8911 192 tempitem.wpn3 = 0;
8912 192 tempitem.wpn4 = 0;
8913 192 tempitem.wpn5 = 0;
8914 192 tempitem.wpn6 = 0;
8915 192 tempitem.wpn7 = 0;
8916 192 tempitem.wpn8 = 0;
8917 192 tempitem.wpn9 = 0;
8918 192 tempitem.wpn10 = 0;
8919 192 break;
8920 }
8921 case itype_wealthmedal:
8922 {
8923 578 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8924 578 tempitem.misc2 = 0;
8925 578 tempitem.misc3 = 0;
8926 578 tempitem.misc4 = 0;
8927 578 tempitem.misc5 = 0;
8928 578 tempitem.misc6 = 0;
8929 578 tempitem.misc7 = 0;
8930 578 tempitem.misc8 = 0;
8931 578 tempitem.misc9 = 0;
8932 578 tempitem.misc10 = 0;
8933 578 tempitem.wpn = 0;
8934 578 tempitem.wpn2 = 0;
8935 578 tempitem.wpn3 = 0;
8936 578 tempitem.wpn4 = 0;
8937 578 tempitem.wpn5 = 0;
8938 578 tempitem.wpn6 = 0;
8939 578 tempitem.wpn7 = 0;
8940 578 tempitem.wpn8 = 0;
8941 578 tempitem.wpn9 = 0;
8942 578 tempitem.wpn10 = 0;
8943 578 break;
8944 }
8945 case itype_heartring:
8946 {
8947 580 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8948 580 tempitem.misc3 = 0;
8949 580 tempitem.misc4 = 0;
8950 580 tempitem.misc5 = 0;
8951 580 tempitem.misc6 = 0;
8952 580 tempitem.misc7 = 0;
8953 580 tempitem.misc8 = 0;
8954 580 tempitem.misc9 = 0;
8955 580 tempitem.misc10 = 0;
8956 580 tempitem.wpn = 0;
8957 580 tempitem.wpn2 = 0;
8958 580 tempitem.wpn3 = 0;
8959 580 tempitem.wpn4 = 0;
8960 580 tempitem.wpn5 = 0;
8961 580 tempitem.wpn6 = 0;
8962 580 tempitem.wpn7 = 0;
8963 580 tempitem.wpn8 = 0;
8964 580 tempitem.wpn9 = 0;
8965 580 tempitem.wpn10 = 0;
8966 580 break;
8967 }
8968 case itype_magicring:
8969 {
8970 776 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8971 776 tempitem.misc3 = 0;
8972 776 tempitem.misc4 = 0;
8973 776 tempitem.misc5 = 0;
8974 776 tempitem.misc6 = 0;
8975 776 tempitem.misc7 = 0;
8976 776 tempitem.misc8 = 0;
8977 776 tempitem.misc9 = 0;
8978 776 tempitem.misc10 = 0;
8979 776 tempitem.wpn = 0;
8980 776 tempitem.wpn2 = 0;
8981 776 tempitem.wpn3 = 0;
8982 776 tempitem.wpn4 = 0;
8983 776 tempitem.wpn5 = 0;
8984 776 tempitem.wpn6 = 0;
8985 776 tempitem.wpn7 = 0;
8986 776 tempitem.wpn8 = 0;
8987 776 tempitem.wpn9 = 0;
8988 776 tempitem.wpn10 = 0;
8989 776 break;
8990 }
8991 case itype_spinscroll2:
8992 {
8993 192 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8994 192 tempitem.misc2 = 0;
8995 192 tempitem.misc3 = 0;
8996 192 tempitem.misc4 = 0;
8997 192 tempitem.misc5 = 0;
8998 192 tempitem.misc6 = 0;
8999 192 tempitem.misc7 = 0;
9000 192 tempitem.misc8 = 0;
9001 192 tempitem.misc9 = 0;
9002 192 tempitem.misc10 = 0;
9003 192 tempitem.wpn = 0;
9004 192 tempitem.wpn2 = 0;
9005 192 tempitem.wpn3 = 0;
9006 192 tempitem.wpn4 = 0;
9007 192 tempitem.wpn5 = 0;
9008 192 tempitem.wpn6 = 0;
9009 192 tempitem.wpn7 = 0;
9010 192 tempitem.wpn8 = 0;
9011 192 tempitem.wpn9 = 0;
9012 192 tempitem.wpn10 = 0;
9013 192 break;
9014 }
9015 case itype_quakescroll2:
9016 {
9017 192 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9018 192 tempitem.misc3 = 0;
9019 192 tempitem.misc4 = 0;
9020 192 tempitem.misc5 = 0;
9021 192 tempitem.misc6 = 0;
9022 192 tempitem.misc7 = 0;
9023 192 tempitem.misc8 = 0;
9024 192 tempitem.misc9 = 0;
9025 192 tempitem.misc10 = 0;
9026 192 tempitem.wpn = 0;
9027 192 tempitem.wpn2 = 0;
9028 192 tempitem.wpn3 = 0;
9029 192 tempitem.wpn4 = 0;
9030 192 tempitem.wpn5 = 0;
9031 192 tempitem.wpn6 = 0;
9032 192 tempitem.wpn7 = 0;
9033 192 tempitem.wpn8 = 0;
9034 192 tempitem.wpn9 = 0;
9035 192 tempitem.wpn10 = 0;
9036 192 break;
9037 }
9038 case itype_agony:
9039 {
9040 192 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9041 192 tempitem.misc2 = 0;
9042 192 tempitem.misc3 = 0;
9043 192 tempitem.misc4 = 0;
9044 192 tempitem.misc5 = 0;
9045 192 tempitem.misc6 = 0;
9046 192 tempitem.misc7 = 0;
9047 192 tempitem.misc8 = 0;
9048 192 tempitem.misc9 = 0;
9049 192 tempitem.misc10 = 0;
9050 192 tempitem.wpn = 0;
9051 192 tempitem.wpn2 = 0;
9052 192 tempitem.wpn3 = 0;
9053 192 tempitem.wpn4 = 0;
9054 192 tempitem.wpn5 = 0;
9055 192 tempitem.wpn6 = 0;
9056 192 tempitem.wpn7 = 0;
9057 192 tempitem.wpn8 = 0;
9058 192 tempitem.wpn9 = 0;
9059 192 tempitem.wpn10 = 0;
9060 192 break;
9061 }
9062 case itype_stompboots:
9063 {
9064 192 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9065 192 tempitem.misc1 = 0;
9066 192 tempitem.misc2 = 0;
9067 192 tempitem.misc3 = 0;
9068 192 tempitem.misc4 = 0;
9069 192 tempitem.misc5 = 0;
9070 192 tempitem.misc6 = 0;
9071 192 tempitem.misc7 = 0;
9072 192 tempitem.misc8 = 0;
9073 192 tempitem.misc9 = 0;
9074 192 tempitem.misc10 = 0;
9075 192 tempitem.wpn = 0;
9076 192 tempitem.wpn2 = 0;
9077 192 tempitem.wpn3 = 0;
9078 192 tempitem.wpn4 = 0;
9079 192 tempitem.wpn5 = 0;
9080 192 tempitem.wpn6 = 0;
9081 192 tempitem.wpn7 = 0;
9082 192 tempitem.wpn8 = 0;
9083 192 tempitem.wpn9 = 0;
9084 192 tempitem.wpn10 = 0;
9085 192 break;
9086 }
9087 case itype_whimsicalring:
9088 {
9089 192 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9090 192 tempitem.misc2 = 0;
9091 192 tempitem.misc3 = 0;
9092 192 tempitem.misc4 = 0;
9093 192 tempitem.misc5 = 0;
9094 192 tempitem.misc6 = 0;
9095 192 tempitem.misc7 = 0;
9096 192 tempitem.misc8 = 0;
9097 192 tempitem.misc9 = 0;
9098 192 tempitem.misc10 = 0;
9099 192 tempitem.wpn = 0;
9100 192 tempitem.wpn2 = 0;
9101 192 tempitem.wpn3 = 0;
9102 192 tempitem.wpn4 = 0;
9103 192 tempitem.wpn5 = 0;
9104 192 tempitem.wpn6 = 0;
9105 192 tempitem.wpn7 = 0;
9106 192 tempitem.wpn8 = 0;
9107 192 tempitem.wpn9 = 0;
9108 192 tempitem.wpn10 = 0;
9109 192 break;
9110 }
9111 case itype_perilring:
9112 {
9113 200 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9114 200 tempitem.misc2 = 0;
9115 200 tempitem.misc3 = 0;
9116 200 tempitem.misc4 = 0;
9117 200 tempitem.misc5 = 0;
9118 200 tempitem.misc6 = 0;
9119 200 tempitem.misc7 = 0;
9120 200 tempitem.misc8 = 0;
9121 200 tempitem.misc9 = 0;
9122 200 tempitem.misc10 = 0;
9123 200 tempitem.wpn = 0;
9124 200 tempitem.wpn2 = 0;
9125 200 tempitem.wpn3 = 0;
9126 200 tempitem.wpn4 = 0;
9127 200 tempitem.wpn5 = 0;
9128 200 tempitem.wpn6 = 0;
9129 200 tempitem.wpn7 = 0;
9130 200 tempitem.wpn8 = 0;
9131 200 tempitem.wpn9 = 0;
9132 200 tempitem.wpn10 = 0;
9133 200 break;
9134 }
9135 case itype_custom1: case itype_custom2: case itype_custom3: case itype_custom4: case itype_custom5:
9136 case itype_custom6: case itype_custom7: case itype_custom8: case itype_custom9: case itype_custom10:
9137 case itype_custom11: case itype_custom12: case itype_custom13: case itype_custom14: case itype_custom15:
9138 case itype_custom16: case itype_custom17: case itype_custom18: case itype_custom19: case itype_custom20:
9139 case itype_bowandarrow: case itype_letterpotion: case itype_misc:
9140 {
9141 6557 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9142 6557 tempitem.misc1 = 0;
9143 6557 tempitem.misc2 = 0;
9144 6557 tempitem.misc3 = 0;
9145 6557 tempitem.misc4 = 0;
9146 6557 tempitem.misc5 = 0;
9147 6557 tempitem.misc6 = 0;
9148 6557 tempitem.misc7 = 0;
9149 6557 tempitem.misc8 = 0;
9150 6557 tempitem.misc9 = 0;
9151 6557 tempitem.misc10 = 0;
9152 6557 tempitem.wpn = 0;
9153 6557 tempitem.wpn2 = 0;
9154 6557 tempitem.wpn3 = 0;
9155 6557 tempitem.wpn4 = 0;
9156 6557 tempitem.wpn5 = 0;
9157 6557 tempitem.wpn6 = 0;
9158 6557 tempitem.wpn7 = 0;
9159 6557 tempitem.wpn8 = 0;
9160 6557 tempitem.wpn9 = 0;
9161 6557 tempitem.wpn10 = 0;
9162 6557 break;
9163 }
9164 }
9165 49664 }
9166 //Port quest rules to items
9167
2/2
✓ Branch 0 taken 100864 times.
✓ Branch 1 taken 49664 times.
150528 if( s_version <= 31)
9168 {
9169
2/2
✓ Branch 0 taken 208 times.
✓ Branch 1 taken 49456 times.
49664 if(tempitem.family == itype_bomb)
9170 {
9171
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 123 times.
208 if ( get_qr(qr_OUCHBOMBS) ) tempitem.flags |= ITEM_FLAG2;
9172 123 else tempitem.flags &= ~ ITEM_FLAG2;
9173 208 }
9174
2/2
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 49262 times.
49456 else if(tempitem.family == itype_sbomb)
9175 {
9176
2/2
✓ Branch 0 taken 87 times.
✓ Branch 1 taken 107 times.
194 if ( get_qr(qr_OUCHBOMBS) ) tempitem.flags |= ITEM_FLAG2;
9177 107 else tempitem.flags &= ~ ITEM_FLAG2;
9178 194 }
9179
9180
2/2
✓ Branch 0 taken 582 times.
✓ Branch 1 taken 48680 times.
49262 else if(tempitem.family == itype_brang)
9181 {
9182
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 582 times.
582 if ( get_qr(qr_BRANGPICKUP) ) tempitem.flags |= ITEM_FLAG4;
9183 582 else tempitem.flags &= ~ ITEM_FLAG4;
9184 582 }
9185
2/2
✓ Branch 0 taken 48470 times.
✓ Branch 1 taken 210 times.
48680 else if(tempitem.family == itype_wand)
9186 {
9187
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 196 times.
210 if ( get_qr(qr_NOWANDMELEE) ) tempitem.flags |= ITEM_FLAG3;
9188 196 else tempitem.flags &= ~ ITEM_FLAG3;
9189 210 }
9190 49664 }
9191
9192 //Port quest rules to items
9193
2/2
✓ Branch 0 taken 100864 times.
✓ Branch 1 taken 49664 times.
150528 if( s_version <= 37)
9194 {
9195
2/2
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 49470 times.
49664 if(tempitem.family == itype_flippers)
9196 {
9197
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 166 times.
194 if ( (get_qr(qr_NODIVING)) ) tempitem.flags |= ITEM_FLAG1;
9198 166 else tempitem.flags &= ~ ITEM_FLAG1;
9199 194 }
9200
2/2
✓ Branch 0 taken 35587 times.
✓ Branch 1 taken 13883 times.
49470 else if(tempitem.family == itype_sword)
9201 {
9202
2/2
✓ Branch 0 taken 462 times.
✓ Branch 1 taken 13421 times.
13883 if ( (get_qr(qr_QUICKSWORD)) ) tempitem.flags |= ITEM_FLAG5;
9203 13421 else tempitem.flags &= ~ ITEM_FLAG5;
9204 13883 }
9205
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 35377 times.
35587 else if(tempitem.family == itype_wand)
9206 {
9207
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 200 times.
210 if ( (get_qr(qr_QUICKSWORD)) ) tempitem.flags |= ITEM_FLAG5;
9208 200 else tempitem.flags &= ~ ITEM_FLAG5;
9209 210 }
9210
4/4
✓ Branch 0 taken 35169 times.
✓ Branch 1 taken 208 times.
✓ Branch 2 taken 426 times.
✓ Branch 3 taken 34743 times.
35377 else if(tempitem.family == itype_book || tempitem.family == itype_candle)
9211 {
9212 //@Emily: What was qrFIREPROOFHERO2 again, and does that also need to enable this?
9213
2/2
✓ Branch 0 taken 216 times.
✓ Branch 1 taken 418 times.
634 if ( (get_qr(qr_FIREPROOFHERO)) ) tempitem.flags |= ITEM_FLAG3;
9214 418 else tempitem.flags &= ~ ITEM_FLAG3;
9215 634 }
9216 49664 }
9217
9218
2/2
✓ Branch 0 taken 100864 times.
✓ Branch 1 taken 49664 times.
150528 if( s_version < 38)
9219 {
9220
4/4
✓ Branch 0 taken 49082 times.
✓ Branch 1 taken 582 times.
✓ Branch 2 taken 386 times.
✓ Branch 3 taken 48696 times.
49664 if(tempitem.family == itype_brang || tempitem.family == itype_hookshot)
9221 {
9222
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 968 times.
968 if(get_qr(qr_BRANGPICKUP)) tempitem.flags |= ITEM_FLAG4;
9223 968 else tempitem.flags &= ~ITEM_FLAG4;
9224
9225
2/2
✓ Branch 0 taken 317 times.
✓ Branch 1 taken 651 times.
968 if(get_qr(qr_Z3BRANG_HSHOT)) tempitem.flags |= ITEM_FLAG5 | ITEM_FLAG6;
9226 651 else tempitem.flags &= ~(ITEM_FLAG5|ITEM_FLAG6);
9227 968 }
9228
2/2
✓ Branch 0 taken 48126 times.
✓ Branch 1 taken 570 times.
48696 else if(tempitem.family == itype_arrow)
9229 {
9230
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 570 times.
570 if(get_qr(qr_BRANGPICKUP)) tempitem.flags |= ITEM_FLAG4;
9231 570 else tempitem.flags &= ~ITEM_FLAG4;
9232
9233
2/2
✓ Branch 0 taken 183 times.
✓ Branch 1 taken 387 times.
570 if(get_qr(qr_Z3BRANG_HSHOT)) tempitem.flags &= ~ITEM_FLAG2;
9234 387 else tempitem.flags |= ITEM_FLAG2;
9235 570 }
9236 49664 }
9237
9238
2/2
✓ Branch 0 taken 100864 times.
✓ Branch 1 taken 49664 times.
150528 if( s_version < 39)
9239 {
9240
6/6
✓ Branch 0 taken 49472 times.
✓ Branch 1 taken 192 times.
✓ Branch 2 taken 49264 times.
✓ Branch 3 taken 208 times.
✓ Branch 4 taken 426 times.
✓ Branch 5 taken 48838 times.
49664 if(tempitem.family == itype_divinefire || tempitem.family == itype_book || tempitem.family == itype_candle)
9241 {
9242
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 810 times.
826 if(get_qr(qr_TEMPCANDLELIGHT)) tempitem.flags |= ITEM_FLAG5;
9243 810 else tempitem.flags &= ~ITEM_FLAG5;
9244 826 }
9245
2/2
✓ Branch 0 taken 407 times.
✓ Branch 1 taken 48431 times.
48838 else if(tempitem.family == itype_potion)
9246 {
9247
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 321 times.
407 if(get_qr(qr_NONBUBBLEMEDICINE))
9248 {
9249 86 tempitem.flags &= ~(ITEM_FLAG3|ITEM_FLAG4);
9250 86 }
9251 else
9252 {
9253 321 tempitem.flags |= ITEM_FLAG3;
9254
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 210 times.
321 if(get_qr(qr_ITEMBUBBLE))tempitem.flags |= ITEM_FLAG4;
9255 210 else tempitem.flags &= ~ITEM_FLAG4;
9256 }
9257 407 }
9258
2/2
✓ Branch 0 taken 48047 times.
✓ Branch 1 taken 384 times.
48431 else if(tempitem.family == itype_triforcepiece)
9259 {
9260
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 338 times.
384 if(get_qr(qr_NONBUBBLETRIFORCE))
9261 {
9262 46 tempitem.flags |= ITEM_FLAG3;
9263
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 26 times.
46 if(get_qr(qr_ITEMBUBBLE))tempitem.flags |= ITEM_FLAG4;
9264 26 else tempitem.flags &= ~ITEM_FLAG4;
9265 46 }
9266 else
9267 {
9268 338 tempitem.flags &= ~(ITEM_FLAG3|ITEM_FLAG4);
9269 }
9270 384 }
9271 49664 }
9272
9273
2/2
✓ Branch 0 taken 100864 times.
✓ Branch 1 taken 49664 times.
150528 if( s_version < 40)
9274 {
9275
4/4
✓ Branch 0 taken 49034 times.
✓ Branch 1 taken 630 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 48834 times.
49664 if(tempitem.family == itype_ring || tempitem.family == itype_perilring)
9276 {
9277
2/2
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 674 times.
830 if(get_qr(qr_RINGAFFECTDAMAGE))tempitem.flags |= ITEM_FLAG1;
9278 674 else tempitem.flags &= ~ITEM_FLAG1;
9279 830 }
9280
8/8
✓ Branch 0 taken 48408 times.
✓ Branch 1 taken 426 times.
✓ Branch 2 taken 34525 times.
✓ Branch 3 taken 13883 times.
✓ Branch 4 taken 34315 times.
✓ Branch 5 taken 210 times.
✓ Branch 6 taken 192 times.
✓ Branch 7 taken 34123 times.
48834 else if(tempitem.family == itype_candle || tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_cbyrna)
9281 {
9282
2/2
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 14603 times.
14711 if(get_qr(qr_SLASHFLIPFIX))tempitem.flags |= ITEM_FLAG8;
9283 14603 else tempitem.flags &= ~ITEM_FLAG8;
9284 14711 }
9285
6/6
✓ Branch 0 taken 35781 times.
✓ Branch 1 taken 13883 times.
✓ Branch 2 taken 35571 times.
✓ Branch 3 taken 210 times.
✓ Branch 4 taken 194 times.
✓ Branch 5 taken 35377 times.
49664 if(tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_hammer)
9286 {
9287
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 14183 times.
14287 if(get_qr(qr_NOITEMMELEE))tempitem.flags |= ITEM_FLAG7;
9288 14183 else tempitem.flags &= ~ITEM_FLAG7;
9289 14287 }
9290
2/2
✓ Branch 0 taken 35185 times.
✓ Branch 1 taken 192 times.
35377 else if(tempitem.family == itype_cbyrna)
9291 {
9292 192 tempitem.flags |= ITEM_FLAG7;
9293 192 }
9294 49664 }
9295
9296
2/2
✓ Branch 0 taken 100864 times.
✓ Branch 1 taken 49664 times.
150528 if( s_version < 41 )
9297 {
9298
2/2
✓ Branch 0 taken 35781 times.
✓ Branch 1 taken 13883 times.
49664 if(tempitem.family == itype_sword)
9299 {
9300
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 13791 times.
13883 if(get_qr(qr_SWORDMIRROR))tempitem.flags |= ITEM_FLAG9;
9301 13791 else tempitem.flags &= ~ITEM_FLAG9;
9302
9303
2/2
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 13707 times.
13883 if(get_qr(qr_SLOWCHARGINGWALK))tempitem.flags |= ITEM_FLAG10;
9304 13707 else tempitem.flags &= ~ITEM_FLAG10;
9305 13883 }
9306 49664 }
9307
9308
2/2
✓ Branch 0 taken 100864 times.
✓ Branch 1 taken 49664 times.
150528 if( s_version < 42 )
9309 {
9310
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 49454 times.
49664 if(tempitem.family == itype_wand)
9311 {
9312
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 196 times.
210 if(get_qr(qr_NOWANDMELEE))tempitem.flags |= ITEM_FLAG3;
9313 196 else tempitem.flags &= ~ITEM_FLAG3;
9314
9315 210 tempitem.flags &= ~ITEM_FLAG6;
9316 210 }
9317
2/2
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 49260 times.
49454 else if(tempitem.family == itype_hammer)
9318 {
9319 194 tempitem.flags &= ~ITEM_FLAG3;
9320 194 }
9321
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 49068 times.
49260 else if(tempitem.family == itype_cbyrna)
9322 {
9323 192 tempitem.flags |= ITEM_FLAG3;
9324
9325 192 tempitem.flags &= ~ITEM_FLAG6;
9326 192 }
9327
2/2
✓ Branch 0 taken 35185 times.
✓ Branch 1 taken 13883 times.
49068 else if(tempitem.family == itype_sword)
9328 {
9329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13883 times.
13883 if(get_qr(qr_MELEEMAGICCOST))tempitem.flags |= ITEM_FLAG6;
9330 13883 else tempitem.flags &= ~ITEM_FLAG6;
9331 13883 }
9332 49664 }
9333
9334
2/2
✓ Branch 0 taken 100864 times.
✓ Branch 1 taken 49664 times.
150528 if( s_version < 43 )
9335 {
9336
2/2
✓ Branch 0 taken 49424 times.
✓ Branch 1 taken 240 times.
49664 if(tempitem.family == itype_whistle)
9337 {
9338
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 236 times.
240 if(get_qr(qr_WHIRLWINDMIRROR))tempitem.flags |= ITEM_FLAG3;
9339 236 else tempitem.flags &= ~ITEM_FLAG3;
9340 240 }
9341 49664 }
9342
9343
2/2
✓ Branch 0 taken 100864 times.
✓ Branch 1 taken 49664 times.
150528 if( s_version < 45 )
9344 {
9345
2/2
✓ Branch 0 taken 49470 times.
✓ Branch 1 taken 194 times.
49664 if(tempitem.family == itype_flippers)
9346 {
9347 194 tempitem.misc1 = 50; //Dive length, default 50 frames -V
9348 194 tempitem.misc2 = 30; //Dive cooldown, default 30 frames -V
9349 194 }
9350 49664 }
9351
9352
2/2
✓ Branch 0 taken 100864 times.
✓ Branch 1 taken 49664 times.
150528 if( s_version < 46 )
9353 {
9354
2/2
✓ Branch 0 taken 49472 times.
✓ Branch 1 taken 192 times.
49664 if(tempitem.family == itype_raft)
9355 {
9356 192 tempitem.misc1 = 1; //Rafting speed modifier; default 1. Negative slows, positive speeds.
9357 192 }
9358 49664 }
9359
2/2
✓ Branch 0 taken 100864 times.
✓ Branch 1 taken 49664 times.
150528 if ( s_version < 34 ) //! set the default counter for older quests.
9360 {
9361
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 49560 times.
49664 if ( (tempitem.flags & ITEM_RUPEE_MAGIC) )
9362 {
9363 104 tempitem.cost_counter[0] = 1;
9364 104 }
9365 else
9366 {
9367
2/2
✓ Branch 0 taken 23040 times.
✓ Branch 1 taken 26520 times.
49560 if(get_qr(qr_ENABLEMAGIC))
9368 23040 tempitem.cost_counter[0] = 4;
9369 else
9370 {
9371 26520 tempitem.cost_amount[0] = 0;
9372 26520 tempitem.cost_counter[0] = -1;
9373 }
9374 }
9375 49664 }
9376
9377
2/2
✓ Branch 0 taken 100864 times.
✓ Branch 1 taken 49664 times.
150528 if ( s_version < 35 ) //new Lens of Truth flags
9378 {
9379
2/2
✓ Branch 0 taken 49478 times.
✓ Branch 1 taken 186 times.
49664 if ( tempitem.family == itype_lens )
9380 {
9381
2/2
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 4 times.
186 if ( get_qr(qr_RAFTLENS) )
9382 {
9383 4 tempitem.flags |= ITEM_FLAG4;
9384 4 }
9385
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 114 times.
186 if ( get_qr(qr_LENSHINTS) )
9386 {
9387 114 tempitem.flags |= ITEM_FLAG1;
9388 114 }
9389
2/2
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 7 times.
186 if ( get_qr(qr_LENSSEESENEMIES) )
9390 {
9391 7 tempitem.flags |= ITEM_FLAG5;
9392 7 }
9393 186 }
9394 49664 }
9395
2/2
✓ Branch 0 taken 100864 times.
✓ Branch 1 taken 49664 times.
150528 if ( s_version < 44 ) //InitD Labels and Sprite Script Data
9396 {
9397
2/2
✓ Branch 0 taken 397312 times.
✓ Branch 1 taken 49664 times.
446976 for ( int32_t q = 0; q < 8; q++ )
9398 {
9399 397312 sprintf(tempitem.initD_label[q],"InitD[%d]",q);
9400 397312 sprintf(tempitem.weapon_initD_label[q],"InitD[%d]",q);
9401 397312 sprintf(tempitem.sprite_initD_label[q],"InitD[%d]",q);
9402 397312 tempitem.sprite_initiald[q] = 0;
9403 397312 }
9404
2/2
✓ Branch 0 taken 99328 times.
✓ Branch 1 taken 49664 times.
148992 for ( int32_t q = 0; q < 2; q++ ) tempitem.sprite_initiala[q] = 0;
9405 49664 tempitem.sprite_script = 0;
9406 49664 }
9407
2/2
✓ Branch 0 taken 100864 times.
✓ Branch 1 taken 49664 times.
150528 if ( s_version < 47 ) //InitD Labels and Sprite Script Data
9408 {
9409 49664 tempitem.pickupflag = 0;
9410 49664 }
9411
9412
2/2
✓ Branch 0 taken 100864 times.
✓ Branch 1 taken 49664 times.
150528 if( s_version < 51 )
9413 {
9414
2/2
✓ Branch 0 taken 49238 times.
✓ Branch 1 taken 426 times.
49664 if( tempitem.family == itype_candle )
9415 {
9416 426 tempitem.misc4 = 50; //Step speed
9417 426 }
9418 49664 }
9419
9420
2/2
✓ Branch 0 taken 100864 times.
✓ Branch 1 taken 49664 times.
150528 if( s_version < 52 )
9421 {
9422
2/2
✓ Branch 0 taken 49074 times.
✓ Branch 1 taken 590 times.
49664 if( tempitem.family == itype_shield )
9423 590 tempitem.flags |= ITEM_FLAG1; //'Block Front' flag
9424 49664 }
9425
2/2
✓ Branch 0 taken 100864 times.
✓ Branch 1 taken 49664 times.
150528 if(s_version < 53)
9426 {
9427
4/4
✓ Branch 0 taken 48692 times.
✓ Branch 1 taken 570 times.
✓ Branch 2 taken 208 times.
✓ Branch 3 taken 194 times.
49664 switch(tempitem.family)
9428 {
9429 case itype_arrow:
9430 570 tempitem.cost_counter[1] = crARROWS;
9431 570 tempitem.cost_amount[1] = 1;
9432 570 break;
9433 case itype_bomb:
9434 208 tempitem.cost_counter[1] = crBOMBS;
9435 208 tempitem.cost_amount[1] = 1;
9436 208 break;
9437 case itype_sbomb:
9438 194 tempitem.cost_counter[1] = crSBOMBS;
9439 194 tempitem.cost_amount[1] = 1;
9440 194 break;
9441 default:
9442 48692 tempitem.cost_counter[1] = crNONE;
9443 48692 tempitem.cost_amount[1] = 0;
9444 48692 }
9445 49664 tempitem.magiccosttimer[1] = 0;
9446 49664 }
9447
2/2
✓ Branch 0 taken 98048 times.
✓ Branch 1 taken 52480 times.
150528 if( s_version < 54 )
9448 {
9449
2/2
✓ Branch 0 taken 52273 times.
✓ Branch 1 taken 207 times.
52480 if( tempitem.family == itype_flippers )
9450 207 tempitem.misc3 = INT_BTN_A; //'Block Front' flag
9451 52480 }
9452
2/2
✓ Branch 0 taken 98048 times.
✓ Branch 1 taken 52480 times.
150528 if(s_version < 55)
9453 {
9454
3/3
✓ Branch 0 taken 406 times.
✓ Branch 1 taken 406 times.
✓ Branch 2 taken 51668 times.
52480 switch(tempitem.family)
9455 {
9456 case itype_spinscroll:
9457 case itype_quakescroll:
9458 406 tempitem.usesound2 = WAV_ZN1CHARGE;
9459 406 break;
9460 case itype_spinscroll2:
9461 case itype_quakescroll2:
9462 406 tempitem.usesound2 = WAV_ZN1CHARGE2;
9463 406 break;
9464 }
9465 52480 }
9466
2/2
✓ Branch 0 taken 98048 times.
✓ Branch 1 taken 52480 times.
150528 if(s_version < 56)
9467 {
9468
4/4
✓ Branch 0 taken 51606 times.
✓ Branch 1 taken 203 times.
✓ Branch 2 taken 452 times.
✓ Branch 3 taken 219 times.
52480 switch(tempitem.family)
9469 {
9470 case itype_divinefire:
9471
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 11 times.
203 SETFLAG(tempitem.flags, ITEM_FLAG9, version < 0x255); //Strong Fire
9472
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 141 times.
203 SETFLAG(tempitem.flags, ITEM_FLAG10, version < 0x250); //Magic Fire
9473 203 tempitem.flags |= ITEM_FLAG11; //Divine Fire
9474 203 break;
9475 case itype_candle:
9476
2/2
✓ Branch 0 taken 225 times.
✓ Branch 1 taken 227 times.
452 SETFLAG(tempitem.flags, ITEM_FLAG9, tempitem.fam_type > 1); //Strong Fire
9477 452 tempitem.flags &= ~ITEM_FLAG10; //Magic Fire
9478 452 tempitem.flags &= ~ITEM_FLAG11; //Divine Fire
9479 452 break;
9480 case itype_book:
9481 219 tempitem.flags |= ITEM_FLAG9; //Strong Fire
9482 219 tempitem.flags |= ITEM_FLAG10; //Magic Fire
9483 219 tempitem.flags &= ~ITEM_FLAG11; //Divine Fire
9484 219 break;
9485 }
9486 52480 }
9487
9488
2/2
✓ Branch 0 taken 142220 times.
✓ Branch 1 taken 8308 times.
150528 if(tempitem.fam_type==0) // Always do this
9489 8308 tempitem.fam_type=1;
9490
9491 150528 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
9492 150528 }
9493
9494 588 return 0;
9495 589 }
9496
9497 static bool did_init_def_items = false;
9498 302542 void init_def_items()
9499 {
9500
2/2
✓ Branch 0 taken 302235 times.
✓ Branch 1 taken 307 times.
302542 if(did_init_def_items) return;
9501 307 did_init_def_items = true;
9502 307 default_items[3].cost_counter[1] = crBOMBS;
9503 307 default_items[13].cost_counter[1] = crARROWS;
9504 307 default_items[14].cost_counter[1] = crARROWS;
9505 307 default_items[48].cost_counter[1] = crSBOMBS;
9506 307 default_items[57].cost_counter[1] = crARROWS;
9507 302542 }
9508 302542 void reset_itembuf(itemdata *item, int32_t id)
9509 {
9510 302542 init_def_items();
9511
2/2
✓ Branch 0 taken 129837 times.
✓ Branch 1 taken 172705 times.
302542 if(id<iLast)
9512 {
9513 // Copy everything *EXCEPT* the tile, misc, cset, frames, speed, delay and ltm.
9514 172705 word tile = item->tile;
9515 172705 byte miscs = item->misc_flags, cset = item->csets, frames = item->frames, speed = item->speed, delay = item->delay;
9516 172705 int32_t ltm = item->ltm;
9517
9518 172705 memcpy(item,&default_items[id],sizeof(itemdata));
9519 172705 item->tile = tile;
9520 172705 item->misc_flags = miscs;
9521 172705 item->csets = cset;
9522 172705 item->frames = frames;
9523 172705 item->speed = speed;
9524 172705 item->delay = delay;
9525 172705 item->ltm = ltm;
9526 172705 }
9527 302542 }
9528
9529 82944 void reset_itemname(int32_t id)
9530 {
9531 82944 sprintf(item_string[id],"zz%03d",id);
9532
9533
2/2
✓ Branch 0 taken 36612 times.
✓ Branch 1 taken 46332 times.
82944 if(id < iLast)
9534 46332 strcpy(item_string[id],old_item_string[id]);
9535 82944 }
9536
9537 589 int32_t readweapons(PACKFILE *f, zquestheader *Header)
9538 {
9539
2/2
✓ Branch 0 taken 565 times.
✓ Branch 1 taken 24 times.
589 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_weapons);
9540
9541 589 word weapons_to_read=MAXWPNS;
9542 int32_t dummy;
9543 byte padding;
9544 wpndata tempweapon;
9545 589 word s_version=0, s_cversion=0;
9546
9547
9548
2/2
✓ Branch 0 taken 583 times.
✓ Branch 1 taken 6 times.
589 if(Header->zelda_version < 0x186)
9549 {
9550 6 weapons_to_read=64;
9551 6 }
9552
9553
2/2
✓ Branch 0 taken 583 times.
✓ Branch 1 taken 6 times.
589 if(Header->zelda_version < 0x185)
9554 {
9555 6 weapons_to_read=32;
9556 6 }
9557
9558
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 565 times.
589 if(Header->zelda_version > 0x192)
9559 {
9560 565 weapons_to_read=0;
9561
9562 //section version info
9563
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 if(!p_igetw(&s_version,f))
9564 {
9565 return qe_invalid;
9566 }
9567
9568 565 FFCore.quest_format[vWeaponSprites] = s_version;
9569
9570 //al_trace("Weapons version %d\n", s_version);
9571
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 if(!p_igetw(&s_cversion,f))
9572 {
9573 return qe_invalid;
9574 }
9575
9576 //section size
9577
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 if(!p_igetl(&dummy,f))
9578 {
9579 return qe_invalid;
9580 }
9581
9582 //finally... section data
9583
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 if(!p_igetw(&weapons_to_read,f))
9584 {
9585 return qe_invalid;
9586 }
9587
9588
2/4
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 565 times.
565 if (!(weapons_to_read >= 0 && weapons_to_read <= MAXWPNS))
9589 {
9590 return qe_invalid;
9591 }
9592 565 }
9593
9594
2/2
✓ Branch 0 taken 526 times.
✓ Branch 1 taken 63 times.
589 if(s_version>2)
9595 {
9596
2/2
✓ Branch 0 taken 134656 times.
✓ Branch 1 taken 526 times.
135182 for(int32_t i=0; i<weapons_to_read; i++)
9597 {
9598 char tempname[64];
9599
9600
1/2
✓ Branch 0 taken 134656 times.
✗ Branch 1 not taken.
134656 if(!pfread(tempname, 64, f))
9601 {
9602 return qe_invalid;
9603 }
9604
9605 134656 weapon_string[i][0] = '\0';
9606 134656 strncat(weapon_string[i], tempname, 64 - 1);
9607 134656 }
9608
9609
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 if(s_version<4)
9610 {
9611 strcpy(weapon_string[iwHover],old_weapon_string[iwHover]);
9612 strcpy(weapon_string[wFIREMAGIC],old_weapon_string[wFIREMAGIC]);
9613 }
9614
9615
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 if(s_version<5)
9616 {
9617 strcpy(weapon_string[iwQuarterHearts],old_weapon_string[iwQuarterHearts]);
9618 }
9619
9620 /*
9621 if (s_version<6)
9622 {
9623 strcpy(weapon_string[iwSideRaft],old_weapon_string[iwSideRaft]);
9624 strcpy(weapon_string[iwSideLadder],old_weapon_string[iwSideLadder]);
9625 }
9626 */
9627 526 }
9628
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 62 times.
63 else if (!should_skip)
9629 {
9630
2/2
✓ Branch 0 taken 15872 times.
✓ Branch 1 taken 62 times.
15934 for(int32_t i=0; i<MAXWPNS; i++)
9631 15872 reset_weaponname(i);
9632 62 }
9633
9634
2/2
✓ Branch 0 taken 142108 times.
✓ Branch 1 taken 589 times.
142697 for(int32_t i=0; i<weapons_to_read; i++)
9635 {
9636 142108 word oldtile = 0;
9637
2/2
✓ Branch 0 taken 99584 times.
✓ Branch 1 taken 42524 times.
142108 if (s_version < 8)
9638 {
9639
1/2
✓ Branch 0 taken 42524 times.
✗ Branch 1 not taken.
42524 if (!p_igetw(&oldtile, f))
9640 return qe_invalid;
9641 42524 }
9642
9643
1/2
✓ Branch 0 taken 142108 times.
✗ Branch 1 not taken.
142108 if(!p_getc(&tempweapon.misc,f))
9644 {
9645 return qe_invalid;
9646 }
9647
9648
1/2
✓ Branch 0 taken 142108 times.
✗ Branch 1 not taken.
142108 if(!p_getc(&tempweapon.csets,f))
9649 {
9650 return qe_invalid;
9651 }
9652
9653
1/2
✓ Branch 0 taken 142108 times.
✗ Branch 1 not taken.
142108 if(!p_getc(&tempweapon.frames,f))
9654 {
9655 return qe_invalid;
9656 }
9657
9658
1/2
✓ Branch 0 taken 142108 times.
✗ Branch 1 not taken.
142108 if(!p_getc(&tempweapon.speed,f))
9659 {
9660 return qe_invalid;
9661 }
9662
9663
1/2
✓ Branch 0 taken 142108 times.
✗ Branch 1 not taken.
142108 if(!p_getc(&tempweapon.type,f))
9664 {
9665 return qe_invalid;
9666 }
9667
9668
2/2
✓ Branch 0 taken 41244 times.
✓ Branch 1 taken 100864 times.
142108 if ( s_version >= 7 )
9669 {
9670
1/2
✓ Branch 0 taken 100864 times.
✗ Branch 1 not taken.
100864 if(!p_igetw(&tempweapon.script,f))
9671 {
9672 return qe_invalid;
9673 }
9674
1/2
✓ Branch 0 taken 100864 times.
✗ Branch 1 not taken.
100864 if(!p_igetl(&tempweapon.tile,f))
9675 {
9676 return qe_invalid;
9677 }
9678 100864 }
9679
2/2
✓ Branch 0 taken 100864 times.
✓ Branch 1 taken 41244 times.
142108 if ( s_version < 7 )
9680 {
9681 41244 tempweapon.tile = oldtile;
9682 41244 }
9683
9684
2/2
✓ Branch 0 taken 137308 times.
✓ Branch 1 taken 4800 times.
142108 if(Header->zelda_version < 0x193)
9685 {
9686
1/2
✓ Branch 0 taken 4800 times.
✗ Branch 1 not taken.
4800 if(!p_getc(&padding,f))
9687 {
9688 return qe_invalid;
9689 }
9690 4800 }
9691
9692
2/2
✓ Branch 0 taken 134656 times.
✓ Branch 1 taken 7452 times.
142108 if(s_version < 6)
9693 {
9694
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 7434 times.
7452 if(i==ewFIRETRAIL)
9695 {
9696 18 tempweapon.misc |= WF_BEHIND;
9697 18 }
9698 else
9699 7434 tempweapon.misc &= ~WF_BEHIND;
9700 7452 }
9701
9702
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 141852 times.
142108 if (!should_skip)
9703 141852 memcpy(&wpnsbuf[i], &tempweapon, sizeof(tempweapon));
9704 142108 }
9705
9706
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 588 times.
589 if (should_skip)
9707 1 return 0;
9708
9709
2/2
✓ Branch 0 taken 526 times.
✓ Branch 1 taken 62 times.
588 if(s_version<2)
9710 {
9711 62 wpnsbuf[wSBOOM]=wpnsbuf[wBOOM];
9712 62 }
9713
9714
2/2
✓ Branch 0 taken 526 times.
✓ Branch 1 taken 62 times.
588 if(s_version<5)
9715 {
9716 62 wpnsbuf[iwQuarterHearts].tile=1;
9717 62 wpnsbuf[iwQuarterHearts].csets=1;
9718 62 }
9719
9720
1/2
✓ Branch 0 taken 588 times.
✗ Branch 1 not taken.
588 if(Header->zelda_version < 0x176)
9721 {
9722 wpnsbuf[iwSpawn] = *((wpndata*)(itemsbuf + iMisc1));
9723 wpnsbuf[iwDeath] = *((wpndata*)(itemsbuf + iMisc2));
9724 memset(&itemsbuf[iMisc1],0,sizeof(itemdata));
9725 memset(&itemsbuf[iMisc2],0,sizeof(itemdata));
9726 }
9727
9728
3/4
✓ Branch 0 taken 570 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
593 if((Header->zelda_version < 0x192)||
9729
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 565 times.
570 ((Header->zelda_version == 0x192)&&(Header->build<129)))
9730 {
9731 18 wpnsbuf[wHSCHAIN_V] = wpnsbuf[wHSCHAIN_H];
9732 18 }
9733
9734
2/2
✓ Branch 0 taken 565 times.
✓ Branch 1 taken 23 times.
588 if((Header->zelda_version < 0x210))
9735 {
9736 23 wpnsbuf[wLSHEAD] = wpnsbuf[wHSHEAD];
9737 23 wpnsbuf[wLSCHAIN_H] = wpnsbuf[wHSCHAIN_H];
9738 23 wpnsbuf[wLSHANDLE] = wpnsbuf[wHSHANDLE];
9739 23 wpnsbuf[wLSCHAIN_V] = wpnsbuf[wHSCHAIN_V];
9740 23 }
9741
9742 588 return 0;
9743 589 }
9744
9745 588 void init_guys(int32_t guyversion)
9746 {
9747
2/2
✓ Branch 0 taken 301056 times.
✓ Branch 1 taken 588 times.
301644 for(int32_t i=0; i<MAXGUYS; i++)
9748 {
9749 301056 guysbuf[i] = default_guys[0];
9750 301056 }
9751
9752
2/2
✓ Branch 0 taken 104076 times.
✓ Branch 1 taken 588 times.
104664 for(int32_t i=0; i<OLDMAXGUYS; i++)
9753 {
9754 104076 guysbuf[i] = default_guys[i];
9755
2/2
✓ Branch 0 taken 102900 times.
✓ Branch 1 taken 1176 times.
104076 guysbuf[i].spr_shadow = (guysbuf[i].family==eeROCK && guysbuf[i].misc10==1) ? iwLargeShadow : iwShadow;
9756 104076 guysbuf[i].spr_death = iwDeath;
9757 104076 guysbuf[i].spr_spawn = iwSpawn;
9758 // Patra fix: 2.10 BSPatras used spDIG. 2.50 Patras use CSet 7.
9759
4/4
✓ Branch 0 taken 10974 times.
✓ Branch 1 taken 93102 times.
✓ Branch 2 taken 10912 times.
✓ Branch 3 taken 62 times.
104076 if(guyversion<=3 && i==ePATRABS)
9760 {
9761 62 guysbuf[i].bosspal=spDIG;
9762 62 guysbuf[i].cset=14;
9763 62 guysbuf[i].misc9=14;
9764 62 }
9765
9766
2/2
✓ Branch 0 taken 93102 times.
✓ Branch 1 taken 10974 times.
104076 if(guyversion<=3)
9767 {
9768 // Rope/Ghini Flash rules
9769
2/2
✓ Branch 0 taken 4071 times.
✓ Branch 1 taken 6903 times.
10974 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
9770 {
9771
2/2
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 39 times.
6903 if(i==eROPE2)
9772 {
9773 39 guysbuf[i].flags2 &= ~guy_flashing;
9774 39 }
9775 6903 }
9776
9777
2/2
✓ Branch 0 taken 9381 times.
✓ Branch 1 taken 1593 times.
10974 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
9778 {
9779
12/12
✓ Branch 0 taken 1584 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 1575 times.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 1566 times.
✓ Branch 5 taken 9 times.
✓ Branch 6 taken 1557 times.
✓ Branch 7 taken 9 times.
✓ Branch 8 taken 1548 times.
✓ Branch 9 taken 9 times.
✓ Branch 10 taken 9 times.
✓ Branch 11 taken 1539 times.
1593 if(i==eBUBBLEST || i==eBUBBLESP || i==eBUBBLESR || i==eBUBBLEIT || i==eBUBBLEIP || i==eBUBBLEIR)
9780 {
9781 54 guysbuf[i].flags2 &= ~guy_flashing;
9782 54 }
9783 1593 }
9784
9785
2/2
✓ Branch 0 taken 10912 times.
✓ Branch 1 taken 62 times.
10974 if(i==eGHINI2)
9786 {
9787
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 4 times.
62 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
9788 {
9789 4 guysbuf[i].flags2 |= guy_blinking;
9790 4 }
9791
9792
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 22 times.
62 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
9793 {
9794 22 guysbuf[i].flags2 |= guy_transparent;
9795 22 }
9796 62 }
9797 10974 }
9798
9799 // Darknut fix
9800
10/10
✓ Branch 0 taken 103488 times.
✓ Branch 1 taken 588 times.
✓ Branch 2 taken 102900 times.
✓ Branch 3 taken 588 times.
✓ Branch 4 taken 102312 times.
✓ Branch 5 taken 588 times.
✓ Branch 6 taken 101724 times.
✓ Branch 7 taken 588 times.
✓ Branch 8 taken 588 times.
✓ Branch 9 taken 101136 times.
104076 if(i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)
9801 {
9802
2/2
✓ Branch 0 taken 2590 times.
✓ Branch 1 taken 350 times.
2940 if(get_qr(qr_NEWENEMYTILES))
9803 {
9804 2590 guysbuf[i].s_tile=guysbuf[i].e_tile+120;
9805 2590 guysbuf[i].s_width=guysbuf[i].e_width;
9806 2590 guysbuf[i].s_height=guysbuf[i].e_height;
9807 2590 }
9808 350 else guysbuf[i].s_tile=860;
9809
9810
2/2
✓ Branch 0 taken 2630 times.
✓ Branch 1 taken 310 times.
2940 if(get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
9811 {
9812 310 guysbuf[i].flags |= guy_bkshield;
9813 310 }
9814 2940 }
9815
9816
4/4
✓ Branch 0 taken 103488 times.
✓ Branch 1 taken 588 times.
✓ Branch 2 taken 104026 times.
✓ Branch 3 taken 50 times.
104076 if((i==eGELTRIB || i==eFGELTRIB) && get_bit(deprecated_rules,qr_OLDTRIBBLES_DEP))
9817 {
9818 50 guysbuf[i].misc3 = (i==eFGELTRIB ? eFZOL : eZOL);
9819 50 }
9820 104076 }
9821 588 }
9822
9823 15872 void reset_weaponname(int32_t i)
9824 {
9825
2/2
✓ Branch 0 taken 5456 times.
✓ Branch 1 taken 10416 times.
15872 if(i<wLast)
9826 {
9827 5456 strcpy(weapon_string[i],old_weapon_string[i]);
9828 5456 }
9829 else
9830 10416 sprintf(weapon_string[i],"zz%03d",i);
9831 15872 }
9832
9833 588 void init_item_drop_sets()
9834 {
9835
2/2
✓ Branch 0 taken 150528 times.
✓ Branch 1 taken 588 times.
151116 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
9836 {
9837 // item_drop_sets[i] = default_item_drop_sets[0];
9838 150528 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
9839 150528 }
9840
9841
2/2
✓ Branch 0 taken 7644 times.
✓ Branch 1 taken 588 times.
8232 for(int32_t i=0; i<isMAX; i++)
9842 {
9843 7644 item_drop_sets[i] = default_item_drop_sets[i];
9844
9845 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
9846
2/2
✓ Branch 0 taken 76440 times.
✓ Branch 1 taken 7644 times.
84084 for(int32_t j=0; j<10; ++j)
9847 {
9848 76440 int32_t it = item_drop_sets[i].item[j];
9849
9850
3/4
✓ Branch 0 taken 53912 times.
✓ Branch 1 taken 22528 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3486 times.
76440 if((itemsbuf[it].family == itype_rupee && ((itemsbuf[it].amount)&0xFFF) == 10)
9851
2/2
✓ Branch 0 taken 3486 times.
✓ Branch 1 taken 50426 times.
53912 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
9852 {
9853 3486 item_drop_sets[i].chance[j+1]=0;
9854 3486 }
9855
4/4
✓ Branch 0 taken 2352 times.
✓ Branch 1 taken 70602 times.
✓ Branch 2 taken 80 times.
✓ Branch 3 taken 2272 times.
72954 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
9856 {
9857 80 item_drop_sets[i].chance[j+1]=0;
9858 80 }
9859
9860 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
9861
2/2
✓ Branch 0 taken 76416 times.
✓ Branch 1 taken 24 times.
76440 if(itemsbuf[it].family == itype_misc)
9862 {
9863 // If a non-gameplay item was selected, then item drop was aborted.
9864 // Reflect this by increasing the 'Nothing' chance accordingly.
9865 24 item_drop_sets[i].chance[0]+=item_drop_sets[i].chance[j+1];
9866 24 item_drop_sets[i].chance[j+1]=0;
9867 24 }
9868 76440 }
9869 7644 }
9870 588 }
9871
9872 588 void init_favorites()
9873 {
9874
2/2
✓ Branch 0 taken 740880 times.
✓ Branch 1 taken 588 times.
741468 for(int32_t i=0; i<MAXFAVORITECOMBOS; i++)
9875 {
9876 740880 favorite_combos[i]=-1;
9877 740880 }
9878 588 }
9879
9880 const char *ctype_name[cMAX]=
9881 {
9882 "cNONE", "cSTAIR", "cCAVE", "cWATER", "cARMOS", "cGRAVE", "cDOCK",
9883 "cUNDEF", "cPUSH_WAIT", "cPUSH_HEAVY", "cPUSH_HW", "cL_STATUE", "cR_STATUE",
9884 "cWALKSLOW", "cCVUP", "cCVDOWN", "cCVLEFT", "cCVRIGHT", "cSWIMWARP", "cDIVEWARP",
9885 "cLADDERHOOKSHOT", "cTRIGNOFLAG", "cTRIGFLAG", "cZELDA", "cSLASH", "cSLASHITEM",
9886 "cPUSH_HEAVY2", "cPUSH_HW2", "cPOUND", "cHSGRAB", "cHSBRIDGE", "cDAMAGE1",
9887 "cDAMAGE2", "cDAMAGE3", "cDAMAGE4", "cC_STATUE", "cTRAP_H", "cTRAP_V", "cTRAP_4",
9888 "cTRAP_LR", "cTRAP_UD", "cPIT", "cHOOKSHOTONLY", "cOVERHEAD", "cNOFLYZONE", "cMIRROR",
9889 "cMIRRORSLASH", "cMIRRORBACKSLASH", "cMAGICPRISM", "cMAGICPRISM4",
9890 "cMAGICSPONGE", "cCAVE2", "cEYEBALL_A", "cEYEBALL_B", "cNOJUMPZONE", "cBUSH",
9891 "cFLOWERS", "cTALLGRASS", "cSHALLOWWATER", "cLOCKBLOCK", "cLOCKBLOCK2",
9892 "cBOSSLOCKBLOCK", "cBOSSLOCKBLOCK2", "cLADDERONLY", "cBSGRAVE",
9893 "cCHEST", "cCHEST2", "cLOCKEDCHEST", "cLOCKEDCHEST2", "cBOSSCHEST", "cBOSSCHEST2",
9894 "cRESET", "cSAVE", "cSAVE2", "cCAVEB", "cCAVEC", "cCAVED",
9895 "cSTAIRB", "cSTAIRC", "cSTAIRD", "cPITB", "cPITC", "cPITD",
9896 "cCAVE2B", "cCAVE2C", "cCAVE2D", "cSWIMWARPB", "cSWIMWARPC", "cSWIMWARPD",
9897 "cDIVEWARPB", "cDIVEWARPC", "cDIVEWARPD", "cSTAIRR", "cPITR",
9898 "cAWARPA", "cAWARPB", "cAWARPC", "cAWARPD", "cAWARPR",
9899 "cSWARPA", "cSWARPB", "cSWARPC", "cSWARPD", "cSWARPR", "cSTRIGNOFLAG", "cSTRIGFLAG",
9900 "cSTEP", "cSTEPSAME", "cSTEPALL", "cSTEPCOPY", "cNOENEMY", "cBLOCKARROW1", "cBLOCKARROW2",
9901 "cBLOCKARROW3", "cBLOCKBRANG1", "cBLOCKBRANG2", "cBLOCKBRANG3", "cBLOCKSBEAM", "cBLOCKALL",
9902 "cBLOCKFIREBALL", "cDAMAGE5", "cDAMAGE6", "cDAMAGE7", "cCHANGE", "cSPINTILE1", "cSPINTILE2",
9903 "cSCREENFREEZE", "cSCREENFREEZEFF", "cNOGROUNDENEMY", "cSLASHNEXT", "cSLASHNEXTITEM", "cBUSHNEXT"
9904 "cSLASHTOUCHY", "cSLASHITEMTOUCHY", "cBUSHTOUCHY", "cFLOWERSTOUCHY", "cTALLGRASSTOUCHY",
9905 "cSLASHNEXTTOUCHY", "cSLASHNEXTITEMTOUCHY", "cBUSHNEXTTOUCHY", "cEYEBALL_4", "cTALLGRASSNEXT",
9906 "cSCRIPT1", "cSCRIPT2", "cSCRIPT3", "cSCRIPT4", "cSCRIPT5",
9907 "cSCRIPT6", "cSCRIPT7", "cSCRIPT8", "cSCRIPT9", "cSCRIPT10",
9908 "cSCRIPT11", "cSCRIPT12", "cSCRIPT13", "cSCRIPT14", "cSCRIPT15",
9909 "cSCRIPT16", "cSCRIPT17", "cSCRIPT18", "cSCRIPT19", "cSCRIPT20"
9910
9911 };
9912
9913 787 int32_t init_combo_classes()
9914 {
9915
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 787 times.
787 zinfo* zi = (load_tmp_zi ? load_tmp_zi : &ZI);
9916
2/2
✓ Branch 0 taken 144021 times.
✓ Branch 1 taken 787 times.
144808 for(int32_t i=0; i<cMAX; i++)
9917 {
9918 144021 combo_class_buf[i] = default_combo_classes[i];
9919
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144021 times.
144021 if ( char const* nm = zi->getComboTypeName(i) )
9920 {
9921 144021 size_t len = strlen(nm);
9922
2/2
✓ Branch 0 taken 9217344 times.
✓ Branch 1 taken 144021 times.
9361365 for ( size_t q = 0; q < 64; q++ )
9923 {
9924
2/2
✓ Branch 0 taken 2109947 times.
✓ Branch 1 taken 7107397 times.
9217344 combo_class_buf[i].name[q] = (q<len ? nm[q] : 0);
9925 9217344 }
9926 144021 }
9927 144021 }
9928
9929 787 return 0;
9930 }
9931
9932 217 int32_t readherosprites2(PACKFILE *f, int32_t v_herosprites, int32_t cv_herosprites)
9933 {
9934
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 171 times.
217 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_herosprites);
9935
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 217 times.
217 if (should_skip) return 0;
9936
9937
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 assert(v_herosprites < 6);
9938 //these are here to bypass compiler warnings about unused arguments
9939 217 cv_herosprites=cv_herosprites;
9940
9941 217 zinit.hero_swim_speed=67; //default
9942 217 setupherotiles(zinit.heroAnimationStyle);
9943 217 setupherodefenses();
9944 217 setupherooffsets();
9945
9946
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 132 times.
217 if(v_herosprites>=0)
9947 {
9948 word tile, tile2;
9949 byte flip, extend, dummy_byte;
9950
9951
2/2
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 132 times.
660 for(int32_t i=0; i<4; i++)
9952 {
9953
1/2
✓ Branch 0 taken 528 times.
✗ Branch 1 not taken.
528 if(!p_igetw(&tile,f))
9954 {
9955 return qe_invalid;
9956 }
9957
9958
1/2
✓ Branch 0 taken 528 times.
✗ Branch 1 not taken.
528 if(!p_getc(&flip,f))
9959 {
9960 return qe_invalid;
9961 }
9962
9963
1/2
✓ Branch 0 taken 528 times.
✗ Branch 1 not taken.
528 if(!p_getc(&extend,f))
9964 {
9965 return qe_invalid;
9966 }
9967
9968 528 walkspr[i][spr_tile]=(int32_t)tile;
9969 528 walkspr[i][spr_flip]=(int32_t)flip;
9970 528 walkspr[i][spr_extend]=(int32_t)extend;
9971 528 }
9972
9973
2/2
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 132 times.
660 for(int32_t i=0; i<4; i++)
9974 {
9975
1/2
✓ Branch 0 taken 528 times.
✗ Branch 1 not taken.
528 if(!p_igetw(&tile,f))
9976 {
9977 return qe_invalid;
9978 }
9979
9980
1/2
✓ Branch 0 taken 528 times.
✗ Branch 1 not taken.
528 if(!p_getc(&flip,f))
9981 {
9982 return qe_invalid;
9983 }
9984
9985
1/2
✓ Branch 0 taken 528 times.
✗ Branch 1 not taken.
528 if(!p_getc(&extend,f))
9986 {
9987 return qe_invalid;
9988 }
9989
9990 528 stabspr[i][spr_tile]=(int32_t)tile;
9991 528 stabspr[i][spr_flip]=(int32_t)flip;
9992 528 stabspr[i][spr_extend]=(int32_t)extend;
9993 528 }
9994
9995
2/2
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 132 times.
660 for(int32_t i=0; i<4; i++)
9996 {
9997
1/2
✓ Branch 0 taken 528 times.
✗ Branch 1 not taken.
528 if(!p_igetw(&tile,f))
9998 {
9999 return qe_invalid;
10000 }
10001
10002
1/2
✓ Branch 0 taken 528 times.
✗ Branch 1 not taken.
528 if(!p_getc(&flip,f))
10003 {
10004 return qe_invalid;
10005 }
10006
10007
1/2
✓ Branch 0 taken 528 times.
✗ Branch 1 not taken.
528 if(!p_getc(&extend,f))
10008 {
10009 return qe_invalid;
10010 }
10011
10012 528 slashspr[i][spr_tile]=(int32_t)tile;
10013 528 slashspr[i][spr_flip]=(int32_t)flip;
10014 528 slashspr[i][spr_extend]=(int32_t)extend;
10015 528 }
10016
10017
2/2
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 132 times.
660 for(int32_t i=0; i<4; i++)
10018 {
10019
1/2
✓ Branch 0 taken 528 times.
✗ Branch 1 not taken.
528 if(!p_igetw(&tile,f))
10020 {
10021 return qe_invalid;
10022 }
10023
10024
1/2
✓ Branch 0 taken 528 times.
✗ Branch 1 not taken.
528 if(!p_getc(&flip,f))
10025 {
10026 return qe_invalid;
10027 }
10028
10029
1/2
✓ Branch 0 taken 528 times.
✗ Branch 1 not taken.
528 if(!p_getc(&extend,f))
10030 {
10031 return qe_invalid;
10032 }
10033
10034 528 floatspr[i][spr_tile]=(int32_t)tile;
10035 528 floatspr[i][spr_flip]=(int32_t)flip;
10036 528 floatspr[i][spr_extend]=(int32_t)extend;
10037 528 }
10038
10039
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
132 if(v_herosprites>1)
10040 {
10041
2/2
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 132 times.
660 for(int32_t i=0; i<4; i++)
10042 {
10043
1/2
✓ Branch 0 taken 528 times.
✗ Branch 1 not taken.
528 if(!p_igetw(&tile,f))
10044 {
10045 return qe_invalid;
10046 }
10047
10048
1/2
✓ Branch 0 taken 528 times.
✗ Branch 1 not taken.
528 if(!p_getc(&flip,f))
10049 {
10050 return qe_invalid;
10051 }
10052
10053
1/2
✓ Branch 0 taken 528 times.
✗ Branch 1 not taken.
528 if(!p_getc(&extend,f))
10054 {
10055 return qe_invalid;
10056 }
10057
10058 528 swimspr[i][spr_tile]=(int32_t)tile;
10059 528 swimspr[i][spr_flip]=(int32_t)flip;
10060 528 swimspr[i][spr_extend]=(int32_t)extend;
10061 528 }
10062 132 }
10063
10064
2/2
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 132 times.
660 for(int32_t i=0; i<4; i++)
10065 {
10066
1/2
✓ Branch 0 taken 528 times.
✗ Branch 1 not taken.
528 if(!p_igetw(&tile,f))
10067 {
10068 return qe_invalid;
10069 }
10070
10071
1/2
✓ Branch 0 taken 528 times.
✗ Branch 1 not taken.
528 if(!p_getc(&flip,f))
10072 {
10073 return qe_invalid;
10074 }
10075
10076
1/2
✓ Branch 0 taken 528 times.
✗ Branch 1 not taken.
528 if(!p_getc(&extend,f))
10077 {
10078 return qe_invalid;
10079 }
10080
10081 528 divespr[i][spr_tile]=(int32_t)tile;
10082 528 divespr[i][spr_flip]=(int32_t)flip;
10083 528 divespr[i][spr_extend]=(int32_t)extend;
10084 528 }
10085
10086
2/2
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 132 times.
660 for(int32_t i=0; i<4; i++)
10087 {
10088
1/2
✓ Branch 0 taken 528 times.
✗ Branch 1 not taken.
528 if(!p_igetw(&tile,f))
10089 {
10090 return qe_invalid;
10091 }
10092
10093
1/2
✓ Branch 0 taken 528 times.
✗ Branch 1 not taken.
528 if(!p_getc(&flip,f))
10094 {
10095 return qe_invalid;
10096 }
10097
10098
1/2
✓ Branch 0 taken 528 times.
✗ Branch 1 not taken.
528 if(!p_getc(&extend,f))
10099 {
10100 return qe_invalid;
10101 }
10102
10103 528 poundspr[i][spr_tile]=(int32_t)tile;
10104 528 poundspr[i][spr_flip]=(int32_t)flip;
10105 528 poundspr[i][spr_extend]=(int32_t)extend;
10106 528 }
10107
10108
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(!p_igetw(&tile,f))
10109 {
10110 return qe_invalid;
10111 }
10112
10113 132 flip=0;
10114
10115
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
132 if(v_herosprites>0)
10116 {
10117
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(!p_getc(&flip,f))
10118 {
10119 return qe_invalid;
10120 }
10121 132 }
10122
10123
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(!p_getc(&extend,f))
10124 {
10125 return qe_invalid;
10126 }
10127
10128 132 castingspr[spr_tile]=(int32_t)tile;
10129 132 castingspr[spr_flip]=(int32_t)flip;
10130 132 castingspr[spr_extend]=(int32_t)extend;
10131
10132
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(v_herosprites>0)
10133 {
10134 132 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10135
2/2
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 132 times.
396 for(int32_t i=0; i<2; i++)
10136 {
10137
2/2
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 264 times.
792 for(int32_t j=0; j<num_holdsprs; j++)
10138 {
10139
1/2
✓ Branch 0 taken 528 times.
✗ Branch 1 not taken.
528 if(!p_igetw(&tile,f))
10140 {
10141 return qe_invalid;
10142 }
10143
10144
1/2
✓ Branch 0 taken 528 times.
✗ Branch 1 not taken.
528 if(!p_getc(&flip,f))
10145 {
10146 return qe_invalid;
10147 }
10148
10149
1/2
✓ Branch 0 taken 528 times.
✗ Branch 1 not taken.
528 if(!p_getc(&extend,f))
10150 {
10151 return qe_invalid;
10152 }
10153
10154 528 holdspr[i][j][spr_tile]=(int32_t)tile;
10155 528 holdspr[i][j][spr_flip]=(int32_t)flip;
10156 528 holdspr[i][j][spr_extend]=(int32_t)extend;
10157 528 }
10158 264 }
10159 132 }
10160 else
10161 {
10162 for(int32_t i=0; i<2; i++)
10163 {
10164 if(!p_igetw(&tile,f))
10165 {
10166 return qe_invalid;
10167 }
10168
10169 if(!p_igetw(&tile2,f))
10170 {
10171 return qe_invalid;
10172 }
10173
10174 if(!p_getc(&extend,f))
10175 {
10176 return qe_invalid;
10177 }
10178
10179 holdspr[i][spr_hold1][spr_tile]=(int32_t)tile;
10180 holdspr[i][spr_hold1][spr_flip]=(int32_t)flip;
10181 holdspr[i][spr_hold1][spr_extend]=(int32_t)extend;
10182 holdspr[i][spr_hold2][spr_tile]=(int32_t)tile2;
10183 holdspr[i][spr_hold2][spr_flip]=(int32_t)flip;
10184 holdspr[i][spr_hold2][spr_extend]=(int32_t)extend;
10185 }
10186 }
10187
10188
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
132 if(v_herosprites>2)
10189 {
10190
2/2
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 132 times.
660 for(int32_t i=0; i<4; i++)
10191 {
10192
1/2
✓ Branch 0 taken 528 times.
✗ Branch 1 not taken.
528 if(!p_igetw(&tile,f))
10193 {
10194 return qe_invalid;
10195 }
10196
10197
1/2
✓ Branch 0 taken 528 times.
✗ Branch 1 not taken.
528 if(!p_getc(&flip,f))
10198 {
10199 return qe_invalid;
10200 }
10201
10202
1/2
✓ Branch 0 taken 528 times.
✗ Branch 1 not taken.
528 if(!p_getc(&extend,f))
10203 {
10204 return qe_invalid;
10205 }
10206
10207 528 jumpspr[i][spr_tile]=(int32_t)tile;
10208 528 jumpspr[i][spr_flip]=(int32_t)flip;
10209 528 jumpspr[i][spr_extend]=(int32_t)extend;
10210 528 }
10211 132 }
10212
10213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
132 if(v_herosprites>3)
10214 {
10215
2/2
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 132 times.
660 for(int32_t i=0; i<4; i++)
10216 {
10217
1/2
✓ Branch 0 taken 528 times.
✗ Branch 1 not taken.
528 if(!p_igetw(&tile,f))
10218 {
10219 return qe_invalid;
10220 }
10221
10222
1/2
✓ Branch 0 taken 528 times.
✗ Branch 1 not taken.
528 if(!p_getc(&flip,f))
10223 {
10224 return qe_invalid;
10225 }
10226
10227
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 528 times.
528 if(!p_getc(&extend,f))
10228 {
10229 return qe_invalid;
10230 }
10231
10232 528 chargespr[i][spr_tile]=(int32_t)tile;
10233 528 chargespr[i][spr_flip]=(int32_t)flip;
10234 528 chargespr[i][spr_extend]=(int32_t)extend;
10235 528 }
10236 132 }
10237
10238
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
132 if(v_herosprites>4)
10239 {
10240
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(!p_getc(&dummy_byte,f))
10241 {
10242 return qe_invalid;
10243 }
10244
10245 132 zinit.hero_swim_speed=(byte)dummy_byte;
10246 132 }
10247
10248 132 memset(frozenspr, 0, sizeof(frozenspr));
10249 132 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10250 132 memset(onfirespr, 0, sizeof(onfirespr));
10251 132 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10252 132 memset(diggingspr, 0, sizeof(diggingspr));
10253 132 memset(usingrodspr, 0, sizeof(usingrodspr));
10254 132 memset(usingcanespr, 0, sizeof(usingcanespr));
10255 132 memset(pushingspr, 0, sizeof(pushingspr));
10256 132 memset(liftingspr, 0, sizeof(liftingspr));
10257 132 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
10258 132 memset(stunnedspr, 0, sizeof(stunnedspr));
10259 132 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
10260 132 memset(fallingspr, 0, sizeof(fallingspr));
10261 132 memset(shockedspr, 0, sizeof(shockedspr));
10262 132 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
10263 132 memset(pullswordspr, 0, sizeof(pullswordspr));
10264 132 memset(readingspr, 0, sizeof(readingspr));
10265 132 memset(slash180spr, 0, sizeof(slash180spr));
10266 132 memset(slashZ4spr, 0, sizeof(slashZ4spr));
10267 132 memset(dashspr, 0, sizeof(dashspr));
10268 132 memset(bonkspr, 0, sizeof(bonkspr));
10269 132 memset(medallionsprs, 0, sizeof(medallionsprs));
10270 132 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
10271 132 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
10272
2/2
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 132 times.
660 for(int32_t q = 0; q < 4; ++q)
10273 {
10274
2/2
✓ Branch 0 taken 1584 times.
✓ Branch 1 taken 528 times.
2112 for(int32_t p = 0; p < 3; ++p)
10275 {
10276 1584 drowningspr[q][p] = divespr[q][p];
10277 1584 drowning_lavaspr[q][p] = divespr[q][p];
10278 1584 }
10279 528 }
10280 132 memset(sideswimspr, 0, sizeof(sideswimspr));
10281 132 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
10282 132 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
10283 132 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
10284 132 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
10285 132 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
10286 132 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
10287 132 }
10288
10289
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 217 times.
217 if(FFCore.quest_format[vInitData] < 34)
10290 {
10291 217 bool fastswim = zinit.hero_swim_speed > 60;
10292 // '2/3' or '1/2'
10293 217 zinit.hero_swim_mult = fastswim ? 2 : 1;
10294 217 zinit.hero_swim_div = fastswim ? 3 : 2;
10295 217 }
10296 217 return 0;
10297 217 }
10298
10299 66980 void setSprite(int32_t* arr, int32_t tile, int32_t flip, int32_t ext)
10300 {
10301 66980 arr[spr_tile] = tile;
10302
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66980 times.
66980 arr[spr_flip] = (flip > 3 ? 0 : flip);
10303
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66980 times.
66980 arr[spr_extend] = (ext > 2 ? 0 : ext);
10304 66980 }
10305 //Used to read the player sprites as int32_t, not word.
10306 394 int32_t readherosprites3(PACKFILE *f, int32_t v_herosprites, int32_t cv_herosprites)
10307 {
10308 //these are here to bypass compiler warnings about unused arguments
10309 394 cv_herosprites=cv_herosprites;
10310
10311 394 zinit.hero_swim_speed=67; //default
10312 394 setupherotiles(zinit.heroAnimationStyle);
10313 394 setupherodefenses();
10314 394 setupherooffsets();
10315
10316 int32_t tile, tile2;
10317 byte flip, extend, dummy_byte;
10318
10319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 394 times.
394 if(v_herosprites>=0)
10320 {
10321
10322
2/2
✓ Branch 0 taken 1576 times.
✓ Branch 1 taken 394 times.
1970 for(int32_t i=0; i<4; i++)
10323 {
10324
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_igetl(&tile,f))
10325 {
10326 return qe_invalid;
10327 }
10328
10329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1576 times.
1576 if(!p_getc(&flip,f))
10330 {
10331 return qe_invalid;
10332 }
10333
10334
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1576 times.
1576 if(!p_getc(&extend,f))
10335 {
10336 return qe_invalid;
10337 }
10338
10339 1576 setSprite(walkspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10340 1576 }
10341
10342
2/2
✓ Branch 0 taken 1576 times.
✓ Branch 1 taken 394 times.
1970 for(int32_t i=0; i<4; i++)
10343 {
10344
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_igetl(&tile,f))
10345 {
10346 return qe_invalid;
10347 }
10348
10349
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1576 times.
1576 if(!p_getc(&flip,f))
10350 {
10351 return qe_invalid;
10352 }
10353
10354
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1576 times.
1576 if(!p_getc(&extend,f))
10355 {
10356 return qe_invalid;
10357 }
10358
10359 1576 setSprite(stabspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10360 1576 }
10361
10362
2/2
✓ Branch 0 taken 1576 times.
✓ Branch 1 taken 394 times.
1970 for(int32_t i=0; i<4; i++)
10363 {
10364
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_igetl(&tile,f))
10365 {
10366 return qe_invalid;
10367 }
10368
10369
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1576 times.
1576 if(!p_getc(&flip,f))
10370 {
10371 return qe_invalid;
10372 }
10373
10374
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1576 times.
1576 if(!p_getc(&extend,f))
10375 {
10376 return qe_invalid;
10377 }
10378
10379 1576 setSprite(slashspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10380 1576 }
10381
10382
2/2
✓ Branch 0 taken 1576 times.
✓ Branch 1 taken 394 times.
1970 for(int32_t i=0; i<4; i++)
10383 {
10384
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_igetl(&tile,f))
10385 {
10386 return qe_invalid;
10387 }
10388
10389
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1576 times.
1576 if(!p_getc(&flip,f))
10390 {
10391 return qe_invalid;
10392 }
10393
10394
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1576 times.
1576 if(!p_getc(&extend,f))
10395 {
10396 return qe_invalid;
10397 }
10398
10399 1576 setSprite(floatspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10400 1576 }
10401
10402
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 394 times.
394 if(v_herosprites>1)
10403 {
10404
2/2
✓ Branch 0 taken 1576 times.
✓ Branch 1 taken 394 times.
1970 for(int32_t i=0; i<4; i++)
10405 {
10406
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_igetl(&tile,f))
10407 {
10408 return qe_invalid;
10409 }
10410
10411
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1576 times.
1576 if(!p_getc(&flip,f))
10412 {
10413 return qe_invalid;
10414 }
10415
10416
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1576 times.
1576 if(!p_getc(&extend,f))
10417 {
10418 return qe_invalid;
10419 }
10420
10421 1576 setSprite(swimspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10422 1576 }
10423 394 }
10424
10425
2/2
✓ Branch 0 taken 1576 times.
✓ Branch 1 taken 394 times.
1970 for(int32_t i=0; i<4; i++)
10426 {
10427
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_igetl(&tile,f))
10428 {
10429 return qe_invalid;
10430 }
10431
10432
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1576 times.
1576 if(!p_getc(&flip,f))
10433 {
10434 return qe_invalid;
10435 }
10436
10437
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1576 times.
1576 if(!p_getc(&extend,f))
10438 {
10439 return qe_invalid;
10440 }
10441
10442 1576 setSprite(divespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10443 1576 }
10444
10445
2/2
✓ Branch 0 taken 1576 times.
✓ Branch 1 taken 394 times.
1970 for(int32_t i=0; i<4; i++)
10446 {
10447
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_igetl(&tile,f))
10448 {
10449 return qe_invalid;
10450 }
10451
10452
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1576 times.
1576 if(!p_getc(&flip,f))
10453 {
10454 return qe_invalid;
10455 }
10456
10457
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1576 times.
1576 if(!p_getc(&extend,f))
10458 {
10459 return qe_invalid;
10460 }
10461
10462 1576 setSprite(poundspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10463 1576 }
10464
10465
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if(!p_igetl(&tile,f))
10466 {
10467 return qe_invalid;
10468 }
10469
10470 394 flip=0;
10471
10472
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 394 times.
394 if(v_herosprites>0)
10473 {
10474
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if(!p_getc(&flip,f))
10475 {
10476 return qe_invalid;
10477 }
10478 394 }
10479
10480
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if(!p_getc(&extend,f))
10481 {
10482 return qe_invalid;
10483 }
10484
10485 394 setSprite(castingspr, int32_t(tile), int32_t(flip), int32_t(extend));
10486
10487
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if(v_herosprites>0)
10488 {
10489 394 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10490
2/2
✓ Branch 0 taken 788 times.
✓ Branch 1 taken 394 times.
1182 for(int32_t i=0; i<2; i++)
10491 {
10492
2/2
✓ Branch 0 taken 2364 times.
✓ Branch 1 taken 788 times.
3152 for(int32_t j=0; j<num_holdsprs; j++)
10493 {
10494
1/2
✓ Branch 0 taken 2364 times.
✗ Branch 1 not taken.
2364 if(!p_igetl(&tile,f))
10495 {
10496 return qe_invalid;
10497 }
10498
10499
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2364 times.
2364 if(!p_getc(&flip,f))
10500 {
10501 return qe_invalid;
10502 }
10503
10504
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2364 times.
2364 if(!p_getc(&extend,f))
10505 {
10506 return qe_invalid;
10507 }
10508
10509 2364 setSprite(holdspr[i][j], int32_t(tile), int32_t(flip), int32_t(extend));
10510 2364 }
10511 788 }
10512 394 }
10513 else
10514 {
10515 for(int32_t i=0; i<2; i++)
10516 {
10517 if(!p_igetl(&tile,f))
10518 {
10519 return qe_invalid;
10520 }
10521
10522 if(!p_igetl(&tile2,f))
10523 {
10524 return qe_invalid;
10525 }
10526
10527 if(!p_getc(&extend,f))
10528 {
10529 return qe_invalid;
10530 }
10531
10532 setSprite(holdspr[i][spr_hold1], int32_t(tile), int32_t(flip), int32_t(extend));
10533 setSprite(holdspr[i][spr_hold2], int32_t(tile2), int32_t(flip), int32_t(extend));
10534 }
10535 }
10536
10537
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 394 times.
394 if(v_herosprites>2)
10538 {
10539
2/2
✓ Branch 0 taken 1576 times.
✓ Branch 1 taken 394 times.
1970 for(int32_t i=0; i<4; i++)
10540 {
10541
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_igetl(&tile,f))
10542 {
10543 return qe_invalid;
10544 }
10545
10546
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1576 times.
1576 if(!p_getc(&flip,f))
10547 {
10548 return qe_invalid;
10549 }
10550
10551
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1576 times.
1576 if(!p_getc(&extend,f))
10552 {
10553 return qe_invalid;
10554 }
10555
10556 1576 setSprite(jumpspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10557 1576 }
10558 394 }
10559
10560
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 394 times.
394 if(v_herosprites>3)
10561 {
10562
2/2
✓ Branch 0 taken 1576 times.
✓ Branch 1 taken 394 times.
1970 for(int32_t i=0; i<4; i++)
10563 {
10564
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_igetl(&tile,f))
10565 {
10566 return qe_invalid;
10567 }
10568
10569
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1576 times.
1576 if(!p_getc(&flip,f))
10570 {
10571 return qe_invalid;
10572 }
10573
10574
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1576 times.
1576 if(!p_getc(&extend,f))
10575 {
10576 return qe_invalid;
10577 }
10578
10579 1576 setSprite(chargespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10580 1576 }
10581 394 }
10582
10583
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 394 times.
394 if(v_herosprites>4)
10584 {
10585
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if(!p_getc(&dummy_byte,f))
10586 {
10587 return qe_invalid;
10588 }
10589
10590 394 zinit.hero_swim_speed=(byte)dummy_byte;
10591 394 }
10592
10593
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if(v_herosprites>6)
10594 {
10595
2/2
✓ Branch 0 taken 1576 times.
✓ Branch 1 taken 394 times.
1970 for(int32_t q = 0; q < 4; ++q)
10596 {
10597
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_igetl(&tile,f))
10598 return qe_invalid;
10599
10600
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1576 times.
1576 if(!p_getc(&flip,f))
10601 return qe_invalid;
10602
10603
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1576 times.
1576 if(!p_getc(&extend,f))
10604 return qe_invalid;
10605
10606 1576 setSprite(frozenspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10607 1576 }
10608
2/2
✓ Branch 0 taken 1576 times.
✓ Branch 1 taken 394 times.
1970 for(int32_t q = 0; q < 4; ++q)
10609 {
10610
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_igetl(&tile,f))
10611 return qe_invalid;
10612
10613
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1576 times.
1576 if(!p_getc(&flip,f))
10614 return qe_invalid;
10615
10616
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1576 times.
1576 if(!p_getc(&extend,f))
10617 return qe_invalid;
10618
10619 1576 setSprite(frozen_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10620 1576 }
10621
10622
2/2
✓ Branch 0 taken 1576 times.
✓ Branch 1 taken 394 times.
1970 for(int32_t q = 0; q < 4; ++q)
10623 {
10624
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_igetl(&tile,f))
10625 return qe_invalid;
10626
10627
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1576 times.
1576 if(!p_getc(&flip,f))
10628 return qe_invalid;
10629
10630
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1576 times.
1576 if(!p_getc(&extend,f))
10631 return qe_invalid;
10632
10633 1576 setSprite(onfirespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10634 1576 }
10635
2/2
✓ Branch 0 taken 1576 times.
✓ Branch 1 taken 394 times.
1970 for(int32_t q = 0; q < 4; ++q)
10636 {
10637
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_igetl(&tile,f))
10638 return qe_invalid;
10639
10640
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1576 times.
1576 if(!p_getc(&flip,f))
10641 return qe_invalid;
10642
10643
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1576 times.
1576 if(!p_getc(&extend,f))
10644 return qe_invalid;
10645
10646 1576 setSprite(onfire_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10647 1576 }
10648
10649
2/2
✓ Branch 0 taken 1576 times.
✓ Branch 1 taken 394 times.
1970 for(int32_t q = 0; q < 4; ++q)
10650 {
10651
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_igetl(&tile,f))
10652 return qe_invalid;
10653
10654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1576 times.
1576 if(!p_getc(&flip,f))
10655 return qe_invalid;
10656
10657
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1576 times.
1576 if(!p_getc(&extend,f))
10658 return qe_invalid;
10659
10660 1576 setSprite(diggingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10661 1576 }
10662
10663
2/2
✓ Branch 0 taken 1576 times.
✓ Branch 1 taken 394 times.
1970 for(int32_t q = 0; q < 4; ++q)
10664 {
10665
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_igetl(&tile,f))
10666 return qe_invalid;
10667
10668
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_getc(&flip,f))
10669 return qe_invalid;
10670
10671
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1576 times.
1576 if(!p_getc(&extend,f))
10672 return qe_invalid;
10673
10674 1576 setSprite(usingrodspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10675 1576 }
10676
10677
2/2
✓ Branch 0 taken 1576 times.
✓ Branch 1 taken 394 times.
1970 for(int32_t q = 0; q < 4; ++q)
10678 {
10679
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_igetl(&tile,f))
10680 return qe_invalid;
10681
10682
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_getc(&flip,f))
10683 return qe_invalid;
10684
10685
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_getc(&extend,f))
10686 return qe_invalid;
10687
10688 1576 setSprite(usingcanespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10689 1576 }
10690
10691
2/2
✓ Branch 0 taken 1576 times.
✓ Branch 1 taken 394 times.
1970 for(int32_t q = 0; q < 4; ++q)
10692 {
10693
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_igetl(&tile,f))
10694 return qe_invalid;
10695
10696
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1576 times.
1576 if(!p_getc(&flip,f))
10697 return qe_invalid;
10698
10699
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1576 times.
1576 if(!p_getc(&extend,f))
10700 return qe_invalid;
10701
10702 1576 setSprite(pushingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10703 1576 }
10704
10705
2/2
✓ Branch 0 taken 1576 times.
✓ Branch 1 taken 394 times.
1970 for(int32_t q = 0; q < 4; ++q)
10706 {
10707
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_igetl(&tile,f))
10708 return qe_invalid;
10709
10710
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_getc(&flip,f))
10711 return qe_invalid;
10712
10713
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_getc(&extend,f))
10714 return qe_invalid;
10715
10716 1576 byte frames = 0;
10717
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 1556 times.
1576 if(v_herosprites > 15)
10718 {
10719
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1556 times.
1556 if(!p_getc(&frames,f))
10720 return qe_invalid;
10721 1556 }
10722
10723 1576 setSprite(liftingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10724 1576 liftingspr[q][spr_frames] = frames;
10725 1576 }
10726
10727
2/2
✓ Branch 0 taken 1576 times.
✓ Branch 1 taken 394 times.
1970 for(int32_t q = 0; q < 4; ++q)
10728 {
10729
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_igetl(&tile,f))
10730 return qe_invalid;
10731
10732
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_getc(&flip,f))
10733 return qe_invalid;
10734
10735
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_getc(&extend,f))
10736 return qe_invalid;
10737
10738 1576 setSprite(liftingwalkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10739 1576 }
10740
10741
2/2
✓ Branch 0 taken 1576 times.
✓ Branch 1 taken 394 times.
1970 for(int32_t q = 0; q < 4; ++q)
10742 {
10743
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1576 times.
1576 if(!p_igetl(&tile,f))
10744 return qe_invalid;
10745
10746
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_getc(&flip,f))
10747 return qe_invalid;
10748
10749
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1576 times.
1576 if(!p_getc(&extend,f))
10750 return qe_invalid;
10751
10752 1576 setSprite(stunnedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10753 1576 }
10754
2/2
✓ Branch 0 taken 1576 times.
✓ Branch 1 taken 394 times.
1970 for(int32_t q = 0; q < 4; ++q)
10755 {
10756
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_igetl(&tile,f))
10757 return qe_invalid;
10758
10759
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_getc(&flip,f))
10760 return qe_invalid;
10761
10762
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_getc(&extend,f))
10763 return qe_invalid;
10764
10765 1576 setSprite(stunned_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10766 1576 }
10767
10768
2/2
✓ Branch 0 taken 1576 times.
✓ Branch 1 taken 394 times.
1970 for(int32_t q = 0; q < 4; ++q)
10769 {
10770
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_igetl(&tile,f))
10771 return qe_invalid;
10772
10773
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_getc(&flip,f))
10774 return qe_invalid;
10775
10776
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1576 times.
1576 if(!p_getc(&extend,f))
10777 return qe_invalid;
10778
10779 1576 setSprite(drowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10780 1576 }
10781
10782
2/2
✓ Branch 0 taken 1576 times.
✓ Branch 1 taken 394 times.
1970 for(int32_t q = 0; q < 4; ++q)
10783 {
10784
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_igetl(&tile,f))
10785 return qe_invalid;
10786
10787
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_getc(&flip,f))
10788 return qe_invalid;
10789
10790
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_getc(&extend,f))
10791 return qe_invalid;
10792
10793 1576 setSprite(drowning_lavaspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10794 1576 }
10795
10796
2/2
✓ Branch 0 taken 1576 times.
✓ Branch 1 taken 394 times.
1970 for(int32_t q = 0; q < 4; ++q)
10797 {
10798
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_igetl(&tile,f))
10799 return qe_invalid;
10800
10801
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_getc(&flip,f))
10802 return qe_invalid;
10803
10804
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_getc(&extend,f))
10805 return qe_invalid;
10806
10807 1576 setSprite(fallingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10808 1576 }
10809
10810
2/2
✓ Branch 0 taken 1576 times.
✓ Branch 1 taken 394 times.
1970 for(int32_t q = 0; q < 4; ++q)
10811 {
10812
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_igetl(&tile,f))
10813 return qe_invalid;
10814
10815
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_getc(&flip,f))
10816 return qe_invalid;
10817
10818
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_getc(&extend,f))
10819 return qe_invalid;
10820
10821 1576 setSprite(shockedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10822 1576 }
10823
2/2
✓ Branch 0 taken 1576 times.
✓ Branch 1 taken 394 times.
1970 for(int32_t q = 0; q < 4; ++q)
10824 {
10825
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_igetl(&tile,f))
10826 return qe_invalid;
10827
10828
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_getc(&flip,f))
10829 return qe_invalid;
10830
10831
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_getc(&extend,f))
10832 return qe_invalid;
10833
10834 1576 setSprite(shocked_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10835 1576 }
10836
10837
2/2
✓ Branch 0 taken 1576 times.
✓ Branch 1 taken 394 times.
1970 for(int32_t q = 0; q < 4; ++q)
10838 {
10839
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_igetl(&tile,f))
10840 return qe_invalid;
10841
10842
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1576 times.
1576 if(!p_getc(&flip,f))
10843 return qe_invalid;
10844
10845
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1576 times.
1576 if(!p_getc(&extend,f))
10846 return qe_invalid;
10847
10848 1576 setSprite(pullswordspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10849 1576 }
10850
10851
2/2
✓ Branch 0 taken 1576 times.
✓ Branch 1 taken 394 times.
1970 for(int32_t q = 0; q < 4; ++q)
10852 {
10853
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_igetl(&tile,f))
10854 return qe_invalid;
10855
10856
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_getc(&flip,f))
10857 return qe_invalid;
10858
10859
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_getc(&extend,f))
10860 return qe_invalid;
10861
10862 1576 setSprite(readingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10863 1576 }
10864
10865
2/2
✓ Branch 0 taken 1576 times.
✓ Branch 1 taken 394 times.
1970 for(int32_t q = 0; q < 4; ++q)
10866 {
10867
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1576 times.
1576 if(!p_igetl(&tile,f))
10868 return qe_invalid;
10869
10870
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_getc(&flip,f))
10871 return qe_invalid;
10872
10873
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1576 times.
1576 if(!p_getc(&extend,f))
10874 return qe_invalid;
10875
10876 1576 setSprite(slash180spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10877 1576 }
10878
10879
2/2
✓ Branch 0 taken 1576 times.
✓ Branch 1 taken 394 times.
1970 for(int32_t q = 0; q < 4; ++q)
10880 {
10881
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_igetl(&tile,f))
10882 return qe_invalid;
10883
10884
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_getc(&flip,f))
10885 return qe_invalid;
10886
10887
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_getc(&extend,f))
10888 return qe_invalid;
10889
10890 1576 setSprite(slashZ4spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10891 1576 }
10892
10893
2/2
✓ Branch 0 taken 1576 times.
✓ Branch 1 taken 394 times.
1970 for(int32_t q = 0; q < 4; ++q)
10894 {
10895
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_igetl(&tile,f))
10896 return qe_invalid;
10897
10898
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_getc(&flip,f))
10899 return qe_invalid;
10900
10901
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_getc(&extend,f))
10902 return qe_invalid;
10903
10904 1576 setSprite(dashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10905 1576 }
10906
10907
2/2
✓ Branch 0 taken 1576 times.
✓ Branch 1 taken 394 times.
1970 for(int32_t q = 0; q < 4; ++q)
10908 {
10909
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_igetl(&tile,f))
10910 return qe_invalid;
10911
10912
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_getc(&flip,f))
10913 return qe_invalid;
10914
10915
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_getc(&extend,f))
10916 return qe_invalid;
10917
10918 1576 setSprite(bonkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10919 1576 }
10920
10921
2/2
✓ Branch 0 taken 1182 times.
✓ Branch 1 taken 394 times.
1576 for(int32_t q = 0; q < 3; ++q) //Not directions; number of medallion sprs
10922 {
10923
1/2
✓ Branch 0 taken 1182 times.
✗ Branch 1 not taken.
1182 if(!p_igetl(&tile,f))
10924 return qe_invalid;
10925
10926
1/2
✓ Branch 0 taken 1182 times.
✗ Branch 1 not taken.
1182 if(!p_getc(&flip,f))
10927 return qe_invalid;
10928
10929
1/2
✓ Branch 0 taken 1182 times.
✗ Branch 1 not taken.
1182 if(!p_getc(&extend,f))
10930 return qe_invalid;
10931
10932 1182 setSprite(medallionsprs[q], int32_t(tile), int32_t(flip), int32_t(extend));
10933 1182 }
10934 394 }
10935 else
10936 {
10937 memset(frozenspr, 0, sizeof(frozenspr));
10938 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10939 memset(onfirespr, 0, sizeof(onfirespr));
10940 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10941 memset(diggingspr, 0, sizeof(diggingspr));
10942 memset(usingrodspr, 0, sizeof(usingrodspr));
10943 memset(usingcanespr, 0, sizeof(usingcanespr));
10944 memset(pushingspr, 0, sizeof(pushingspr));
10945 memset(liftingspr, 0, sizeof(liftingspr));
10946 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
10947 memset(stunnedspr, 0, sizeof(stunnedspr));
10948 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
10949 memset(fallingspr, 0, sizeof(fallingspr));
10950 memset(shockedspr, 0, sizeof(shockedspr));
10951 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
10952 memset(pullswordspr, 0, sizeof(pullswordspr));
10953 memset(readingspr, 0, sizeof(readingspr));
10954 memset(slash180spr, 0, sizeof(slash180spr));
10955 memset(slashZ4spr, 0, sizeof(slashZ4spr));
10956 memset(dashspr, 0, sizeof(dashspr));
10957 memset(bonkspr, 0, sizeof(bonkspr));
10958 memset(medallionsprs, 0, sizeof(medallionsprs));
10959 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
10960 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
10961 for(int32_t q = 0; q < 4; ++q)
10962 {
10963 for(int32_t p = 0; p < 3; ++p)
10964 {
10965 drowningspr[q][p] = divespr[q][p];
10966 drowning_lavaspr[q][p] = divespr[q][p];
10967 }
10968 }
10969 }
10970
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if (v_herosprites > 8)
10971 {
10972
2/2
✓ Branch 0 taken 1576 times.
✓ Branch 1 taken 394 times.
1970 for(int32_t q = 0; q < 4; ++q)
10973 {
10974
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_igetl(&tile,f))
10975 return qe_invalid;
10976
10977
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1576 times.
1576 if(!p_getc(&flip,f))
10978 return qe_invalid;
10979
10980
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1576 times.
1576 if(!p_getc(&extend,f))
10981 return qe_invalid;
10982
10983 1576 setSprite(sideswimspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10984 1576 }
10985 394 }
10986 else
10987 {
10988 memset(sideswimspr, 0, sizeof(sideswimspr));
10989 }
10990
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if (v_herosprites > 9)
10991 {
10992
2/2
✓ Branch 0 taken 1576 times.
✓ Branch 1 taken 394 times.
1970 for(int32_t q = 0; q < 4; ++q)
10993 {
10994
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_igetl(&tile,f))
10995 return qe_invalid;
10996
10997
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1576 times.
1576 if(!p_getc(&flip,f))
10998 return qe_invalid;
10999
11000
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1576 times.
1576 if(!p_getc(&extend,f))
11001 return qe_invalid;
11002
11003 1576 setSprite(sideswimslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11004 1576 }
11005
2/2
✓ Branch 0 taken 1576 times.
✓ Branch 1 taken 394 times.
1970 for(int32_t q = 0; q < 4; ++q)
11006 {
11007
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_igetl(&tile,f))
11008 return qe_invalid;
11009
11010
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1576 times.
1576 if(!p_getc(&flip,f))
11011 return qe_invalid;
11012
11013
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1576 times.
1576 if(!p_getc(&extend,f))
11014 return qe_invalid;
11015
11016 1576 setSprite(sideswimstabspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11017 1576 }
11018
2/2
✓ Branch 0 taken 1576 times.
✓ Branch 1 taken 394 times.
1970 for(int32_t q = 0; q < 4; ++q)
11019 {
11020
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_igetl(&tile,f))
11021 return qe_invalid;
11022
11023
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1576 times.
1576 if(!p_getc(&flip,f))
11024 return qe_invalid;
11025
11026
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1576 times.
1576 if(!p_getc(&extend,f))
11027 return qe_invalid;
11028
11029 1576 setSprite(sideswimpoundspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11030 1576 }
11031
2/2
✓ Branch 0 taken 1576 times.
✓ Branch 1 taken 394 times.
1970 for(int32_t q = 0; q < 4; ++q)
11032 {
11033
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_igetl(&tile,f))
11034 return qe_invalid;
11035
11036
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1576 times.
1576 if(!p_getc(&flip,f))
11037 return qe_invalid;
11038
11039
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1576 times.
1576 if(!p_getc(&extend,f))
11040 return qe_invalid;
11041
11042 1576 setSprite(sideswimchargespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11043 1576 }
11044 394 }
11045 else
11046 {
11047 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
11048 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
11049 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
11050 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
11051 }
11052
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if (v_herosprites > 10)
11053 {
11054
2/2
✓ Branch 0 taken 1576 times.
✓ Branch 1 taken 394 times.
1970 for(int32_t q = 0; q < 4; ++q)
11055 {
11056 int32_t hmr;
11057
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1576 times.
1576 if(!p_igetl(&hmr,f))
11058 return qe_invalid;
11059
11060 1576 hammeroffsets[q] = hmr;
11061 1576 }
11062 394 }
11063 else
11064 {
11065 for(int32_t q = 0; q < 4; ++q) hammeroffsets[q] = 0;
11066 }
11067
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if (v_herosprites > 11)
11068 {
11069
2/2
✓ Branch 0 taken 1182 times.
✓ Branch 1 taken 394 times.
1576 for(int32_t q = 0; q < 3; ++q)
11070 {
11071
1/2
✓ Branch 0 taken 1182 times.
✗ Branch 1 not taken.
1182 if(!p_igetl(&tile,f))
11072 return qe_invalid;
11073
11074
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1182 times.
1182 if(!p_getc(&flip,f))
11075 return qe_invalid;
11076
11077
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1182 times.
1182 if(!p_getc(&extend,f))
11078 return qe_invalid;
11079
11080 1182 setSprite(sideswimholdspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11081 1182 }
11082 394 }
11083 else
11084 {
11085 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
11086 }
11087
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if (v_herosprites > 12)
11088 {
11089
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if(!p_igetl(&tile,f))
11090 return qe_invalid;
11091
11092
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if(!p_getc(&flip,f))
11093 return qe_invalid;
11094
11095
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if(!p_getc(&extend,f))
11096 return qe_invalid;
11097 394 setSprite(sideswimcastingspr, int32_t(tile), int32_t(flip), int32_t(extend));
11098
11099 394 }
11100 else
11101 {
11102 memset(sideswimcastingspr, 0, sizeof(sideswimcastingspr));
11103 }
11104
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if (v_herosprites > 13)
11105 {
11106
2/2
✓ Branch 0 taken 1576 times.
✓ Branch 1 taken 394 times.
1970 for(int32_t q = 0; q < 4; ++q)
11107 {
11108
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_igetl(&tile,f))
11109 return qe_invalid;
11110
11111
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1576 times.
1576 if(!p_getc(&flip,f))
11112 return qe_invalid;
11113
11114
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1576 times.
1576 if(!p_getc(&extend,f))
11115 return qe_invalid;
11116
11117 1576 setSprite(sidedrowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11118 1576 }
11119 394 }
11120 else
11121 {
11122 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
11123 }
11124
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if (v_herosprites > 14)
11125 {
11126
2/2
✓ Branch 0 taken 1576 times.
✓ Branch 1 taken 394 times.
1970 for(int32_t q = 0; q < 4; ++q)
11127 {
11128
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if(!p_igetl(&tile,f))
11129 return qe_invalid;
11130
11131
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1576 times.
1576 if(!p_getc(&flip,f))
11132 return qe_invalid;
11133
11134
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1576 times.
1576 if(!p_getc(&extend,f))
11135 return qe_invalid;
11136
11137 1576 setSprite(revslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11138 1576 }
11139 394 }
11140 else
11141 {
11142 memset(revslashspr, 0, sizeof(revslashspr));
11143 }
11144
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if (v_herosprites > 7)
11145 {
11146 394 int32_t num_defense = wMax;
11147 394 byte def = 0;
11148
11149 //Set num_defense accordingly if changes to enum require version upgrade - Jman
11150 /*if(v_herosprites > [x])
11151 * {
11152 * num_defense = 146 //value of wMax on version 8
11153 * }
11154 */
11155
11156
2/2
✓ Branch 0 taken 57524 times.
✓ Branch 1 taken 394 times.
57918 for (int32_t q = 0; q < num_defense; q++)
11157 {
11158
1/2
✓ Branch 0 taken 57524 times.
✗ Branch 1 not taken.
57524 if (!p_getc(&def, f))
11159 return qe_invalid;
11160
11161 57524 hero_defence[q] = def;
11162 57524 }
11163 394 }
11164 else
11165 {
11166 int32_t num_defense = wMax;
11167 for (int32_t q = 0; q < num_defense; q++)
11168 {
11169 hero_defence[q] = 0;
11170 }
11171 }
11172 394 }
11173
11174
2/2
✓ Branch 0 taken 383 times.
✓ Branch 1 taken 11 times.
394 if(FFCore.quest_format[vInitData] < 34)
11175 {
11176 11 bool fastswim = zinit.hero_swim_speed > 60;
11177 // '2/3' or '1/2'
11178 11 zinit.hero_swim_mult = fastswim ? 2 : 1;
11179 11 zinit.hero_swim_div = fastswim ? 3 : 2;
11180 11 }
11181 394 return 0;
11182 394 }
11183
11184
11185 526 int32_t readherosprites(PACKFILE *f, zquestheader *Header)
11186 {
11187 //these are here to bypass compiler warnings about unused arguments
11188 526 Header=Header;
11189
11190 dword dummy;
11191 526 word s_version=0, s_cversion=0;
11192
11193 //section version info
11194
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 526 times.
526 if(!p_igetw(&s_version,f))
11195 {
11196 return qe_invalid;
11197 }
11198
11199 526 FFCore.quest_format[vHeroSprites] = s_version;
11200
11201 //al_trace("Player sprites version %d\n", s_version);
11202
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 if(!p_igetw(&s_cversion,f))
11203 {
11204 return qe_invalid;
11205 }
11206
11207 //section size
11208
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 if(!p_igetl(&dummy,f))
11209 {
11210 return qe_invalid;
11211 }
11212
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 132 times.
526 if ( s_version >= 6 )
11213 {
11214 //al_trace("Reading Player Sprites v6\n");
11215 394 return readherosprites3(f, s_version, dummy);
11216 }
11217 132 else return readherosprites2(f, s_version, dummy);
11218 526 }
11219
11220 150 int32_t read_old_subscreens(PACKFILE *f, word s_version)
11221 {
11222 150 subscreens_active.clear();
11223 150 subscreens_passive.clear();
11224 150 subscreens_overlay.clear();
11225
2/2
✓ Branch 0 taken 19200 times.
✓ Branch 1 taken 150 times.
19350 for(int32_t i=0; i<MAXCUSTOMSUBSCREENS; i++)
11226 {
11227 subscreen_group g;
11228 19200 memset(&g,0,sizeof(subscreen_group));
11229 19200 int32_t ret = read_one_old_subscreen(f, &g, s_version);
11230
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19200 times.
19200 if(ret!=0)
11231 return ret;
11232
2/2
✓ Branch 0 taken 778 times.
✓ Branch 1 taken 18422 times.
19200 if(g.objects[0].type == ssoNULL) continue;
11233
2/2
✓ Branch 0 taken 342 times.
✓ Branch 1 taken 436 times.
778 auto& vec = g.ss_type == sstPASSIVE ? subscreens_passive : subscreens_active;
11234 778 ZCSubscreen& sub = vec.emplace_back();
11235 778 sub.load_old(g);
11236 778 }
11237
11238 150 return 0;
11239 150 }
11240
11241 19200 int32_t read_one_old_subscreen(PACKFILE *f, subscreen_group* g, word s_version)
11242 {
11243 19200 int32_t numsub=0;
11244 19200 byte temp_ss=0;
11245 subscreen_object temp_sub_stack;
11246 19200 subscreen_object *temp_sub = &temp_sub_stack;
11247
11248 char tempname[64];
11249
11250 // FWIW I never saw anything bigger than 20.
11251 #define MAX_DP1_LEN 1024
11252 char tempdp1[MAX_DP1_LEN];
11253
11254
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19200 times.
19200 if(!pfread(tempname,64,f))
11255 {
11256 return qe_invalid;
11257 }
11258
11259
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19200 times.
19200 if(s_version > 1)
11260 {
11261
1/2
✓ Branch 0 taken 19200 times.
✗ Branch 1 not taken.
19200 if(!p_getc(&temp_ss,f))
11262 {
11263 return qe_invalid;
11264 }
11265 19200 }
11266
11267
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19200 times.
19200 if(s_version < 4)
11268 {
11269 uint8_t tmp=0;
11270
11271 if(!p_getc(&tmp,f))
11272 {
11273 return qe_invalid;
11274 }
11275
11276 numsub = (int32_t)tmp;
11277 }
11278 else
11279 {
11280 word tmp;
11281
11282
1/2
✓ Branch 0 taken 19200 times.
✗ Branch 1 not taken.
19200 if(!p_igetw(&tmp, f))
11283 {
11284 return qe_invalid;
11285 }
11286
11287 19200 numsub = (int32_t)tmp;
11288 }
11289
11290 int32_t j;
11291
11292
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 49278 times.
✓ Branch 2 taken 30078 times.
✓ Branch 3 taken 19200 times.
49278 for(j=0; (j<MAXSUBSCREENITEMS&&j<numsub); j++)
11293 {
11294 30078 memset(temp_sub,0,sizeof(subscreen_object));
11295
11296
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30078 times.
30078 switch(g->objects[j].type)
11297 {
11298 case ssoTEXT:
11299 case ssoTEXTBOX:
11300 case ssoCURRENTITEMTEXT:
11301 case ssoCURRENTITEMCLASSTEXT:
11302 if(g->objects[j].dp1 != NULL) delete [](char *)g->objects[j].dp1;
11303
11304 //fall through
11305 default:
11306 30078 memset(&g->objects[j],0,sizeof(subscreen_object));
11307 30078 break;
11308 }
11309
11310
1/2
✓ Branch 0 taken 30078 times.
✗ Branch 1 not taken.
30078 if(!p_getc(&(temp_sub->type),f))
11311 return qe_invalid;
11312
11313
1/2
✓ Branch 0 taken 30078 times.
✗ Branch 1 not taken.
30078 if(!p_getc(&(temp_sub->pos),f))
11314 return qe_invalid;
11315
11316
1/2
✓ Branch 0 taken 30078 times.
✗ Branch 1 not taken.
30078 if(s_version < 5)
11317 {
11318 switch(temp_sub->pos)
11319 {
11320 case 0:
11321 temp_sub->pos = sspUP | sspDOWN | sspSCROLLING;
11322 break;
11323
11324 case 1:
11325 temp_sub->pos = sspUP;
11326 break;
11327
11328 case 2:
11329 temp_sub->pos = sspDOWN;
11330 break;
11331
11332 default:
11333 temp_sub->pos = 0;
11334 }
11335 }
11336
11337
1/2
✓ Branch 0 taken 30078 times.
✗ Branch 1 not taken.
30078 if(!p_igetw(&(temp_sub->x),f))
11338 return qe_invalid;
11339
11340
1/2
✓ Branch 0 taken 30078 times.
✗ Branch 1 not taken.
30078 if(!p_igetw(&(temp_sub->y),f))
11341 return qe_invalid;
11342
11343
1/2
✓ Branch 0 taken 30078 times.
✗ Branch 1 not taken.
30078 if(!p_igetw(&(temp_sub->w),f))
11344 return qe_invalid;
11345
11346
1/2
✓ Branch 0 taken 30078 times.
✗ Branch 1 not taken.
30078 if(!p_igetw(&(temp_sub->h),f))
11347 return qe_invalid;
11348
11349
1/2
✓ Branch 0 taken 30078 times.
✗ Branch 1 not taken.
30078 if(!p_getc(&(temp_sub->colortype1),f))
11350 return qe_invalid;
11351
11352
1/2
✓ Branch 0 taken 30078 times.
✗ Branch 1 not taken.
30078 if(!p_igetw(&(temp_sub->color1),f))
11353 return qe_invalid;
11354
11355
1/2
✓ Branch 0 taken 30078 times.
✗ Branch 1 not taken.
30078 if(!p_getc(&(temp_sub->colortype2),f))
11356 return qe_invalid;
11357
11358
1/2
✓ Branch 0 taken 30078 times.
✗ Branch 1 not taken.
30078 if(!p_igetw(&(temp_sub->color2),f))
11359 return qe_invalid;
11360
11361
1/2
✓ Branch 0 taken 30078 times.
✗ Branch 1 not taken.
30078 if(!p_getc(&(temp_sub->colortype3),f))
11362 return qe_invalid;
11363
11364
1/2
✓ Branch 0 taken 30078 times.
✗ Branch 1 not taken.
30078 if(!p_igetw(&(temp_sub->color3),f))
11365 return qe_invalid;
11366
11367
1/2
✓ Branch 0 taken 30078 times.
✗ Branch 1 not taken.
30078 if(!p_igetd(&(temp_sub->d1),f))
11368 return qe_invalid;
11369
11370
1/2
✓ Branch 0 taken 30078 times.
✗ Branch 1 not taken.
30078 if(!p_igetd(&(temp_sub->d2),f))
11371 return qe_invalid;
11372
11373
1/2
✓ Branch 0 taken 30078 times.
✗ Branch 1 not taken.
30078 if(!p_igetd(&(temp_sub->d3),f))
11374 return qe_invalid;
11375
11376
1/2
✓ Branch 0 taken 30078 times.
✗ Branch 1 not taken.
30078 if(!p_igetd(&(temp_sub->d4),f))
11377 return qe_invalid;
11378
11379
1/2
✓ Branch 0 taken 30078 times.
✗ Branch 1 not taken.
30078 if(!p_igetd(&(temp_sub->d5),f))
11380 return qe_invalid;
11381
11382
1/2
✓ Branch 0 taken 30078 times.
✗ Branch 1 not taken.
30078 if(!p_igetd(&(temp_sub->d6),f))
11383 return qe_invalid;
11384
11385
1/2
✓ Branch 0 taken 30078 times.
✗ Branch 1 not taken.
30078 if(!p_igetd(&(temp_sub->d7),f))
11386 return qe_invalid;
11387
11388
1/2
✓ Branch 0 taken 30078 times.
✗ Branch 1 not taken.
30078 if(!p_igetd(&(temp_sub->d8),f))
11389 return qe_invalid;
11390
11391
1/2
✓ Branch 0 taken 30078 times.
✗ Branch 1 not taken.
30078 if(!p_igetd(&(temp_sub->d9),f))
11392 return qe_invalid;
11393
11394
1/2
✓ Branch 0 taken 30078 times.
✗ Branch 1 not taken.
30078 if(!p_igetd(&(temp_sub->d10),f))
11395 return qe_invalid;
11396
11397
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30078 times.
30078 if(s_version < 2)
11398 {
11399 if(!p_igetl(&(temp_sub->speed),f))
11400 return qe_invalid;
11401
11402 if(!p_igetl(&(temp_sub->delay),f))
11403 return qe_invalid;
11404
11405 if(!p_igetl(&(temp_sub->frame),f))
11406 return qe_invalid;
11407 }
11408 else
11409 {
11410
1/2
✓ Branch 0 taken 30078 times.
✗ Branch 1 not taken.
30078 if(!p_getc(&(temp_sub->speed),f))
11411 return qe_invalid;
11412
11413
1/2
✓ Branch 0 taken 30078 times.
✗ Branch 1 not taken.
30078 if(!p_getc(&(temp_sub->delay),f))
11414 return qe_invalid;
11415
11416
1/2
✓ Branch 0 taken 30078 times.
✗ Branch 1 not taken.
30078 if(!p_igetw(&(temp_sub->frame),f))
11417 return qe_invalid;
11418 }
11419
11420 30078 int32_t temp_size=0;
11421
11422 // bool deletets = false;
11423
4/4
✓ Branch 0 taken 13143 times.
✓ Branch 1 taken 2424 times.
✓ Branch 2 taken 14317 times.
✓ Branch 3 taken 194 times.
30078 switch(temp_sub->type)
11424 {
11425 case ssoTEXT:
11426 case ssoTEXTBOX:
11427 case ssoCURRENTITEMTEXT:
11428 case ssoCURRENTITEMCLASSTEXT:
11429 {
11430 word temptempsize;
11431
11432
1/2
✓ Branch 0 taken 2424 times.
✗ Branch 1 not taken.
2424 if(!p_igetw(&temptempsize,f))
11433 {
11434 return qe_invalid;
11435 }
11436
11437 //temptempsize = temp1 + (temp2 << 8);
11438 2424 temp_size = (int32_t)temptempsize;
11439 2424 uint32_t char_length = temp_size+2;
11440
1/2
✓ Branch 0 taken 2424 times.
✗ Branch 1 not taken.
2424 if (char_length > MAX_DP1_LEN)
11441 {
11442 return qe_invalid;
11443 }
11444 2424 tempdp1[char_length - 1] = '\0';
11445
11446
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2424 times.
2424 if(temp_size)
11447
1/2
✓ Branch 0 taken 2424 times.
✗ Branch 1 not taken.
2424 if(!pfread(tempdp1,temp_size+1,f))
11448 return qe_invalid;
11449 2424 break;
11450 }
11451
11452 case ssoLIFEMETER:
11453
1/2
✓ Branch 0 taken 194 times.
✗ Branch 1 not taken.
194 if(get_bit(deprecated_rules, 12) != 0) // qr_24HC
11454 temp_sub->d3 = 1;
11455
11456
1/2
✓ Branch 0 taken 194 times.
✗ Branch 1 not taken.
194 if(!p_getc(&(temp_sub->dp1),f))
11457 return qe_invalid;
11458
11459 194 break;
11460
11461
11462 case ssoCURRENTITEM:
11463
11464
1/2
✓ Branch 0 taken 13143 times.
✗ Branch 1 not taken.
13143 if(s_version < 6)
11465 {
11466 switch(temp_sub->d1)
11467 {
11468 case ssiBOMB:
11469 temp_sub->d1 = itype_bomb;
11470 break;
11471
11472 case ssiSWORD:
11473 temp_sub->d1 = itype_sword;
11474 break;
11475
11476 case ssiSHIELD:
11477 temp_sub->d1 = itype_shield;
11478 break;
11479
11480 case ssiCANDLE:
11481 temp_sub->d1 = itype_candle;
11482 break;
11483
11484 case ssiLETTER:
11485 temp_sub->d1 = itype_letter;
11486 break;
11487
11488 case ssiPOTION:
11489 temp_sub->d1 = itype_potion;
11490 break;
11491
11492 case ssiLETTERPOTION:
11493 temp_sub->d1 = itype_letterpotion;
11494 break;
11495
11496 case ssiBOW:
11497 temp_sub->d1 = itype_bow;
11498 break;
11499
11500 case ssiARROW:
11501 temp_sub->d1 = itype_arrow;
11502 break;
11503
11504 case ssiBOWANDARROW:
11505 temp_sub->d1 = itype_bowandarrow;
11506 break;
11507
11508 case ssiBAIT:
11509 temp_sub->d1 = itype_bait;
11510 break;
11511
11512 case ssiRING:
11513 temp_sub->d1 = itype_ring;
11514 break;
11515
11516 case ssiBRACELET:
11517 temp_sub->d1 = itype_bracelet;
11518 break;
11519
11520 case ssiMAP:
11521 temp_sub->d1 = itype_map;
11522 break;
11523
11524 case ssiCOMPASS:
11525 temp_sub->d1 = itype_compass;
11526 break;
11527
11528 case ssiBOSSKEY:
11529 temp_sub->d1 = itype_bosskey;
11530 break;
11531
11532 case ssiMAGICKEY:
11533 temp_sub->d1 = itype_magickey;
11534 break;
11535
11536 case ssiBRANG:
11537 temp_sub->d1 = itype_brang;
11538 break;
11539
11540 case ssiWAND:
11541 temp_sub->d1 = itype_wand;
11542 break;
11543
11544 case ssiRAFT:
11545 temp_sub->d1 = itype_raft;
11546 break;
11547
11548 case ssiLADDER:
11549 temp_sub->d1 = itype_ladder;
11550 break;
11551
11552 case ssiWHISTLE:
11553 temp_sub->d1 = itype_whistle;
11554 break;
11555
11556 case ssiBOOK:
11557 temp_sub->d1 = itype_book;
11558 break;
11559
11560 case ssiWALLET:
11561 temp_sub->d1 = itype_wallet;
11562 break;
11563
11564 case ssiSBOMB:
11565 temp_sub->d1 = itype_sbomb;
11566 break;
11567
11568 case ssiHCPIECE:
11569 temp_sub->d1 = itype_heartpiece;
11570 break;
11571
11572 case ssiAMULET:
11573 temp_sub->d1 = itype_amulet;
11574 break;
11575
11576 case ssiFLIPPERS:
11577 temp_sub->d1 = itype_flippers;
11578 break;
11579
11580 case ssiHOOKSHOT:
11581 temp_sub->d1 = itype_hookshot;
11582 break;
11583
11584 case ssiLENS:
11585 temp_sub->d1 = itype_lens;
11586 break;
11587
11588 case ssiHAMMER:
11589 temp_sub->d1 = itype_hammer;
11590 break;
11591
11592 case ssiBOOTS:
11593 temp_sub->d1 = itype_boots;
11594 break;
11595
11596 case ssiDIVINEFIRE:
11597 temp_sub->d1 = itype_divinefire;
11598 break;
11599
11600 case ssiDIVINEESCAPE:
11601 temp_sub->d1 = itype_divineescape;
11602 break;
11603
11604 case ssiDIVINEPROTECTION:
11605 temp_sub->d1 = itype_divineprotection;
11606 break;
11607
11608 case ssiQUIVER:
11609 temp_sub->d1 = itype_quiver;
11610 break;
11611
11612 case ssiBOMBBAG:
11613 temp_sub->d1 = itype_bombbag;
11614 break;
11615
11616 case ssiCBYRNA:
11617 temp_sub->d1 = itype_cbyrna;
11618 break;
11619
11620 case ssiROCS:
11621 temp_sub->d1 = itype_rocs;
11622 break;
11623
11624 case ssiHOVERBOOTS:
11625 temp_sub->d1 = itype_hoverboots;
11626 break;
11627
11628 case ssiSPINSCROLL:
11629 temp_sub->d1 = itype_spinscroll;
11630 break;
11631
11632 case ssiCROSSSCROLL:
11633 temp_sub->d1 = itype_crossscroll;
11634 break;
11635
11636 case ssiQUAKESCROLL:
11637 temp_sub->d1 = itype_quakescroll;
11638 break;
11639
11640 case ssiWHISPRING:
11641 temp_sub->d1 = itype_whispring;
11642 break;
11643
11644 case ssiCHARGERING:
11645 temp_sub->d1 = itype_chargering;
11646 break;
11647
11648 case ssiPERILSCROLL:
11649 temp_sub->d1 = itype_perilscroll;
11650 break;
11651
11652 case ssiWEALTHMEDAL:
11653 temp_sub->d1 = itype_wealthmedal;
11654 break;
11655
11656 case ssiHEARTRING:
11657 temp_sub->d1 = itype_heartring;
11658 break;
11659
11660 case ssiMAGICRING:
11661 temp_sub->d1 = itype_magicring;
11662 break;
11663
11664 case ssiSPINSCROLL2:
11665 temp_sub->d1 = itype_spinscroll2;
11666 break;
11667
11668 case ssiQUAKESCROLL2:
11669 temp_sub->d1 = itype_quakescroll2;
11670 break;
11671
11672 case ssiAGONY:
11673 temp_sub->d1 = itype_agony;
11674 break;
11675
11676 case ssiSTOMPBOOTS:
11677 temp_sub->d1 = itype_stompboots;
11678 break;
11679
11680 case ssiWHIMSICALRING:
11681 temp_sub->d1 = itype_whimsicalring;
11682 break;
11683
11684 case ssiPERILRING:
11685 temp_sub->d1 = itype_perilring;
11686 break;
11687
11688 default:
11689 temp_sub->d1 += itype_custom1 - ssiMAX;
11690 }
11691 }
11692
11693 //fall-through
11694 default:
11695
1/2
✓ Branch 0 taken 27460 times.
✗ Branch 1 not taken.
27460 if(!p_getc(&(temp_sub->dp1),f))
11696 return qe_invalid;
11697
11698 27460 break;
11699 }
11700
11701
2/2
✓ Branch 0 taken 9237 times.
✓ Branch 1 taken 20841 times.
30078 if(s_version < 7)
11702 {
11703
3/3
✓ Branch 0 taken 17305 times.
✓ Branch 1 taken 920 times.
✓ Branch 2 taken 2616 times.
20841 switch(temp_sub->type)
11704 {
11705 case ssoMAGICGAUGE:
11706 {
11707
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 824 times.
920 if(!temp_sub->d9)
11708 824 temp_sub->d9 = -1; //-1 now represents 'always'
11709 920 break;
11710 }
11711 case ssoLIFEGAUGE:
11712 2616 temp_sub->d9 = 0; //Unused, doesn't do anything? Clear it...
11713 2616 break;
11714 }
11715 20841 }
11716
11717
3/3
✓ Branch 0 taken 2424 times.
✓ Branch 1 taken 26550 times.
✓ Branch 2 taken 1104 times.
30078 switch(temp_sub->type)
11718 {
11719 case ssoTEXT:
11720 case ssoTEXTBOX:
11721 case ssoCURRENTITEMTEXT:
11722 case ssoCURRENTITEMCLASSTEXT:
11723
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2424 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2424 if(g->objects[j].dp1 != NULL) delete[](char *)g->objects[j].dp1;
11724
11725 2424 memcpy(&g->objects[j],temp_sub,sizeof(subscreen_object));
11726 2424 g->objects[j].dp1 = new char[temp_size+2];
11727 2424 strcpy((char*)g->objects[j].dp1,tempdp1);
11728 2424 break;
11729
11730 case ssoCOUNTER:
11731
1/2
✓ Branch 0 taken 1104 times.
✗ Branch 1 not taken.
1104 if(s_version<3)
11732 {
11733 temp_sub->d6=(temp_sub->d6?1:0)+(temp_sub->d8?2:0);
11734 temp_sub->d8=0;
11735 }
11736
11737 default:
11738 27654 memcpy(&g->objects[j],temp_sub,sizeof(subscreen_object));
11739 27654 break;
11740 }
11741
11742 30078 g->name[0] = '\0';
11743 30078 strncat(g->name, tempname, 64 - 1);
11744 30078 g->ss_type = temp_ss;
11745 30078 }
11746
11747
2/2
✓ Branch 0 taken 4885122 times.
✓ Branch 1 taken 19200 times.
4904322 for(j=numsub; j<MAXSUBSCREENITEMS; j++)
11748 {
11749 //clear all unused object in this subscreen -DD
11750
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4885122 times.
4885122 switch(g->objects[j].type)
11751 {
11752 case ssoTEXT:
11753 case ssoTEXTBOX:
11754 case ssoCURRENTITEMTEXT:
11755 case ssoCURRENTITEMCLASSTEXT:
11756 if(g->objects[j].dp1 != NULL) delete [](char *)g->objects[j].dp1;
11757
11758 //fall through
11759 default:
11760 4885122 memset(&g->objects[j],0,sizeof(subscreen_object));
11761 4885122 break;
11762 }
11763 4885122 }
11764
11765 19200 return 0;
11766 19200 }
11767
11768 526 int32_t readsubscreens(PACKFILE *f)
11769 {
11770 word s_version, s_cversion;
11771 dword dummy;
11772
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 526 times.
526 if(!p_igetw(&s_version,f))
11773 return qe_invalid;
11774 526 FFCore.quest_format[vSubscreen] = s_version;
11775
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 if(!p_igetw(&s_cversion,f))
11776 return qe_invalid;
11777
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 if(!p_igetl(&dummy,f)) //section size
11778 return qe_invalid;
11779
11780
2/2
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 376 times.
526 if(s_version < 8)
11781 150 return read_old_subscreens(f,s_version);
11782
11783 376 subscreens_active.clear();
11784 376 subscreens_passive.clear();
11785 376 subscreens_overlay.clear();
11786
11787 byte sz;
11788
1/2
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
376 if(!p_getc(&sz,f))
11789 return qe_invalid;
11790
2/2
✓ Branch 0 taken 712 times.
✓ Branch 1 taken 376 times.
1088 for(byte q = 0; q < sz; ++q)
11791 {
11792 712 ZCSubscreen& tmp = subscreens_active.emplace_back();
11793
1/2
✓ Branch 0 taken 712 times.
✗ Branch 1 not taken.
712 if (auto ret = tmp.read(f, s_version))
11794 return ret;
11795 712 }
11796
1/2
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
376 if(!p_getc(&sz,f))
11797 return qe_invalid;
11798
2/2
✓ Branch 0 taken 1494 times.
✓ Branch 1 taken 376 times.
1870 for(byte q = 0; q < sz; ++q)
11799 {
11800 1494 ZCSubscreen& tmp = subscreens_passive.emplace_back();
11801
1/2
✓ Branch 0 taken 1494 times.
✗ Branch 1 not taken.
1494 if (auto ret = tmp.read(f, s_version))
11802 return ret;
11803 1494 }
11804
1/2
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
376 if(!p_getc(&sz,f))
11805 return qe_invalid;
11806
2/2
✓ Branch 0 taken 524 times.
✓ Branch 1 taken 376 times.
900 for(byte q = 0; q < sz; ++q)
11807 {
11808 524 ZCSubscreen& tmp = subscreens_overlay.emplace_back();
11809
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 524 times.
524 if (auto ret = tmp.read(f, s_version))
11810 return ret;
11811 524 }
11812 376 return 0;
11813 526 }
11814
11815 void reset_subscreen(subscreen_group *tempss)
11816 {
11817 for(int32_t i=0; i<MAXSUBSCREENITEMS; ++i)
11818 {
11819 switch(tempss->objects[i].type)
11820 {
11821 case ssoTEXT:
11822 case ssoTEXTBOX:
11823 case ssoCURRENTITEMTEXT:
11824 case ssoCURRENTITEMCLASSTEXT:
11825 if(tempss->objects[i].dp1 != NULL) delete [](char *)tempss->objects[i].dp1;
11826
11827 //fall through
11828 default:
11829 memset(&tempss->objects[i],0,sizeof(subscreen_object));
11830 break;
11831 }
11832 }
11833 }
11834
11835 85 void reset_subscreens()
11836 {
11837 85 subscreens_active.clear();
11838 85 subscreens_passive.clear();
11839 85 subscreens_overlay.clear();
11840 85 }
11841
11842 85 int32_t setupsubscreens()
11843 {
11844 85 reset_subscreens();
11845 //return 0;
11846
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 170 times.
255 for(int q = 0; q < 2; ++q)
11847 {
11848 170 subscreens_active.emplace_back();
11849 170 subscreens_passive.emplace_back();
11850 170 }
11851 85 int32_t tempsubscreen=subscr_mode;
11852
11853
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 if(tempsubscreen>=ssdtMAX)
11854 tempsubscreen=0;
11855
11856
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
✗ Branch 2 not taken.
85 switch(tempsubscreen)
11857 {
11858 case ssdtOLD:
11859 case ssdtNEWSUBSCR:
11860 case ssdtREV2:
11861 case ssdtBSZELDA:
11862 case ssdtBSZELDAMODIFIED:
11863 case ssdtBSZELDAENHANCED:
11864 case ssdtBSZELDACOMPLETE:
11865 {
11866 85 subscreens_active[0].load_old(default_subscreen_active[tempsubscreen][0]);
11867 85 subscreens_active[0].sub_type=sstACTIVE;
11868 85 subscreens_active[0].name = "Active Subscreen (Triforce)";
11869 85 subscreens_active[1].load_old(default_subscreen_active[tempsubscreen][1]);
11870 85 subscreens_active[1].sub_type=sstACTIVE;
11871 85 subscreens_active[1].name = "Active Subscreen (Dungeon Map)";
11872 85 subscreens_passive[0].load_old(default_subscreen_passive[tempsubscreen][0]);
11873 85 subscreens_passive[0].sub_type=sstPASSIVE;
11874 85 subscreens_passive[0].name = "Passive Subscreen (Magic)";
11875 85 subscreens_passive[1].load_old(default_subscreen_passive[tempsubscreen][1]);
11876 85 subscreens_passive[1].sub_type=sstPASSIVE;
11877 85 subscreens_passive[1].name = "Passive Subscreen (No Magic)";
11878 85 break;
11879 }
11880
11881 case ssdtZ3:
11882 {
11883 subscreens_active[0].load_old(z3_active_a);
11884 subscreens_active[0].sub_type=sstACTIVE;
11885 subscreens_active[1].load_old(z3_active_ab);
11886 subscreens_active[1].sub_type=sstACTIVE;
11887 subscreens_passive[0].load_old(z3_passive_a);
11888 subscreens_passive[0].sub_type=sstPASSIVE;
11889 subscreens_passive[1].load_old(z3_passive_ab);
11890 subscreens_passive[1].sub_type=sstPASSIVE;
11891 break;
11892 }
11893 }
11894 85 subscr_mode = ssdtMAX;
11895 85 return 0;
11896 }
11897
11898 extern script_data *ffscripts[NUMSCRIPTFFC];
11899 extern script_data *itemscripts[NUMSCRIPTITEM];
11900 extern script_data *guyscripts[NUMSCRIPTGUYS];
11901 extern script_data *lwpnscripts[NUMSCRIPTWEAPONS];
11902 extern script_data *ewpnscripts[NUMSCRIPTWEAPONS];
11903 extern script_data *globalscripts[NUMSCRIPTGLOBAL];
11904 extern script_data *genericscripts[NUMSCRIPTSGENERIC];
11905 extern script_data *playerscripts[NUMSCRIPTPLAYER];
11906 extern script_data *screenscripts[NUMSCRIPTSCREEN];
11907 extern script_data *dmapscripts[NUMSCRIPTSDMAP];
11908 extern script_data *itemspritescripts[NUMSCRIPTSITEMSPRITE];
11909 extern script_data *comboscripts[NUMSCRIPTSCOMBODATA];
11910 extern script_data *subscreenscripts[NUMSCRIPTSSUBSCREEN];
11911
11912 static std::vector<const script_data*> read_scripts;
11913
11914 1052 int32_t readffscript(PACKFILE *f, zquestheader *Header)
11915 {
11916 int32_t dummy;
11917 1052 word s_version=0, s_cversion=0, zmeta_version=0;
11918 1052 byte numscripts=0;
11919 1052 numscripts=numscripts; //to avoid unused variables warnings
11920 int32_t ret;
11921 1052 read_scripts.clear();
11922
11923 //section version info
11924
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1052 times.
1052 if(!p_igetw(&s_version,f))
11925 {
11926 return qe_invalid;
11927 }
11928
11929 1052 FFCore.quest_format[vFFScript] = s_version;
11930
11931
1/2
✓ Branch 0 taken 1052 times.
✗ Branch 1 not taken.
1052 if(!p_igetw(&s_cversion,f))
11932 {
11933 return qe_invalid;
11934 }
11935
11936
2/2
✓ Branch 0 taken 658 times.
✓ Branch 1 taken 394 times.
1052 if(s_version >= 18)
11937 {
11938
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if(!p_igetw(&zmeta_version,f))
11939 {
11940 return qe_invalid;
11941 }
11942 394 }
11943
11944 //al_trace("Scripts version %d\n", s_version);
11945 //section size
11946
1/2
✓ Branch 0 taken 1052 times.
✗ Branch 1 not taken.
1052 if(!p_igetl(&dummy,f))
11947 {
11948 return qe_invalid;
11949 }
11950
11951
2/2
✓ Branch 0 taken 912 times.
✓ Branch 1 taken 140 times.
1052 if ( FFCore.quest_format[vLastCompile] < 13 ) FFCore.quest_format[vLastCompile] = s_version;
11952 1052 al_trace("Loaded scripts last compiled in ZScript version: %d\n", (FFCore.quest_format[vLastCompile]));
11953
11954 //finally... section data
11955
2/2
✓ Branch 0 taken 269312 times.
✓ Branch 1 taken 1050 times.
270364 for(int32_t i = 0; i < ((s_version < 2) ? NUMSCRIPTFFCOLD : NUMSCRIPTFFC); i++)
11956 {
11957 269312 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &ffscripts[i], zmeta_version);
11958
11959
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if (ret)
11960 {
11961 return qe_invalid;
11962 }
11963 269312 }
11964
11965 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
11966 * This fixes changes to sprite jump values introduced in early 2.55 alphas.
11967 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
11968 * there was a version bump a week before a change that broke stuff.
11969 */
11970
7/8
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 656 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 394 times.
✓ Branch 4 taken 394 times.
✓ Branch 5 taken 394 times.
✓ Branch 6 taken 394 times.
✓ Branch 7 taken 394 times.
1050 if(((Header->zelda_version < 0x253)||((Header->zelda_version == 0x253)&&(Header->build<33))||((Header->zelda_version > 0x253) && s_version < 12)))
11971 {
11972 1444 set_qr(qr_SPRITE_JUMP_IS_TRUNCATED,1);
11973 1444 }
11974
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 132 times.
526 if(s_version < 19)
11975 {
11976 132 set_qr(qr_FLUCTUATING_ENEMY_JUMP,1);
11977 132 }
11978
11979
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 526 times.
526 if(s_version > 1)
11980 {
11981
2/2
✓ Branch 0 taken 134656 times.
✓ Branch 1 taken 526 times.
135182 for(int32_t i = 0; i < NUMSCRIPTITEM; i++)
11982 {
11983 134656 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &itemscripts[i], zmeta_version);
11984
11985
1/2
✓ Branch 0 taken 134656 times.
✗ Branch 1 not taken.
134656 if (ret)
11986 {
11987 return qe_invalid;
11988 }
11989 134656 }
11990
11991
2/2
✓ Branch 0 taken 134656 times.
✓ Branch 1 taken 526 times.
135182 for(int32_t i = 0; i < NUMSCRIPTGUYS; i++)
11992 {
11993 134656 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &guyscripts[i], zmeta_version);
11994
11995
1/2
✓ Branch 0 taken 134656 times.
✗ Branch 1 not taken.
134656 if (ret)
11996 {
11997 return qe_invalid;
11998 }
11999 134656 }
12000
12001
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 script_data *fake = new script_data(ScriptType::None, 0);
12002
2/2
✓ Branch 0 taken 134656 times.
✓ Branch 1 taken 526 times.
135182 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12003 {
12004 134656 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &fake, zmeta_version);
12005
12006
1/2
✓ Branch 0 taken 134656 times.
✗ Branch 1 not taken.
134656 if (ret)
12007 {
12008 return qe_invalid;
12009 }
12010 134656 }
12011
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 526 times.
526 delete fake;
12012
12013
2/2
✓ Branch 0 taken 134656 times.
✓ Branch 1 taken 526 times.
135182 for(int32_t i = 0; i < NUMSCRIPTSCREEN; i++)
12014 {
12015 134656 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &screenscripts[i], zmeta_version);
12016
12017
1/2
✓ Branch 0 taken 134656 times.
✗ Branch 1 not taken.
134656 if (ret)
12018 {
12019 return qe_invalid;
12020 }
12021 134656 }
12022
12023
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 132 times.
526 if(s_version > 16)
12024 {
12025
2/2
✓ Branch 0 taken 3152 times.
✓ Branch 1 taken 394 times.
3546 for(int32_t i = 0; i < NUMSCRIPTGLOBAL; ++i)
12026 {
12027 3152 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12028
12029
1/2
✓ Branch 0 taken 3152 times.
✗ Branch 1 not taken.
3152 if (ret)
12030 {
12031 return qe_invalid;
12032 }
12033 3152 }
12034 394 }
12035
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
132 else if(s_version > 13)
12036 {
12037 for(int32_t i = 0; i < NUMSCRIPTGLOBAL255OLD; ++i)
12038 {
12039 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12040
12041 if (ret)
12042 {
12043 return qe_invalid;
12044 }
12045 }
12046
12047 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12048 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12049
12050 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVE);
12051 }
12052
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 else if(s_version > 4)
12053 {
12054
2/2
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 132 times.
660 for(int32_t i = 0; i < NUMSCRIPTGLOBAL253; ++i)
12055 {
12056 528 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12057
12058
1/2
✓ Branch 0 taken 528 times.
✗ Branch 1 not taken.
528 if (ret)
12059 {
12060 return qe_invalid;
12061 }
12062 528 }
12063
12064
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
132 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12065
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12066
12067
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONLAUNCH);
12068
12069
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
132 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12070
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12071
12072
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONCONTGAME);
12073
12074
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
132 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12075
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 delete globalscripts[GLOBAL_SCRIPT_F6];
12076
12077
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 globalscripts[GLOBAL_SCRIPT_F6] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_F6);
12078
12079
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
132 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12080
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12081
12082
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVE);
12083 132 }
12084 else
12085 {
12086 for(int32_t i = 0; i < NUMSCRIPTGLOBALOLD; i++)
12087 {
12088 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12089
12090 if (ret)
12091 {
12092 return qe_invalid;
12093 }
12094 }
12095
12096 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12097 delete globalscripts[GLOBAL_SCRIPT_ONSAVELOAD];
12098
12099 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVELOAD);
12100
12101 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12102 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12103
12104 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONLAUNCH);
12105
12106 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12107 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12108
12109 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONCONTGAME);
12110
12111 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12112 delete globalscripts[GLOBAL_SCRIPT_F6];
12113
12114 globalscripts[GLOBAL_SCRIPT_F6] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_F6);
12115
12116 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12117 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12118
12119 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVE);
12120 }
12121
12122
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 132 times.
526 if(s_version > 10) //expanded the number of Player scripts to 5.
12123 {
12124
2/2
✓ Branch 0 taken 1970 times.
✓ Branch 1 taken 394 times.
2364 for(int32_t i = 0; i < NUMSCRIPTPLAYER; i++)
12125 {
12126 1970 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &playerscripts[i], zmeta_version);
12127
12128
1/2
✓ Branch 0 taken 1970 times.
✗ Branch 1 not taken.
1970 if (ret)
12129 {
12130 return qe_invalid;
12131 }
12132 1970 }
12133 394 }
12134 else
12135 {
12136
2/2
✓ Branch 0 taken 396 times.
✓ Branch 1 taken 132 times.
528 for(int32_t i = 0; i < NUMSCRIPTHEROOLD; i++)
12137 {
12138 396 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &playerscripts[i], zmeta_version);
12139
12140
1/2
✓ Branch 0 taken 396 times.
✗ Branch 1 not taken.
396 if (ret)
12141 {
12142 return qe_invalid;
12143 }
12144 396 }
12145
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(playerscripts[3] != NULL)
12146
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 delete playerscripts[3];
12147
12148
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 playerscripts[3] = new script_data(ScriptType::Player, 3);
12149
12150
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(playerscripts[4] != NULL)
12151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
132 delete playerscripts[4];
12152
12153
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 playerscripts[4] = new script_data(ScriptType::Player, 4);
12154 }
12155
3/4
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 132 times.
✓ Branch 2 taken 394 times.
✗ Branch 3 not taken.
526 if(s_version > 8 && s_version < 10)
12156 {
12157
12158 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12159 {
12160 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &ewpnscripts[i], zmeta_version);
12161
12162 if (ret)
12163 {
12164 return qe_invalid;
12165 }
12166 }
12167 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12168 {
12169 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &dmapscripts[i], zmeta_version);
12170
12171 if (ret)
12172 {
12173 return qe_invalid;
12174 }
12175 }
12176
12177 }
12178
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 394 times.
526 if(s_version >= 10)
12179 {
12180
2/2
✓ Branch 0 taken 100864 times.
✓ Branch 1 taken 394 times.
101258 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12181 {
12182 100864 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &lwpnscripts[i], zmeta_version);
12183
12184
1/2
✓ Branch 0 taken 100864 times.
✗ Branch 1 not taken.
100864 if (ret)
12185 {
12186 return qe_invalid;
12187 }
12188 100864 }
12189
2/2
✓ Branch 0 taken 100864 times.
✓ Branch 1 taken 394 times.
101258 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12190 {
12191 100864 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &ewpnscripts[i], zmeta_version);
12192
12193
1/2
✓ Branch 0 taken 100864 times.
✗ Branch 1 not taken.
100864 if (ret)
12194 {
12195 return qe_invalid;
12196 }
12197 100864 }
12198
2/2
✓ Branch 0 taken 100864 times.
✓ Branch 1 taken 394 times.
101258 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12199 {
12200 100864 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &dmapscripts[i], zmeta_version);
12201
12202
1/2
✓ Branch 0 taken 100864 times.
✗ Branch 1 not taken.
100864 if (ret)
12203 {
12204 return qe_invalid;
12205 }
12206 100864 }
12207
12208 394 }
12209
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 394 times.
526 if(s_version >=12)
12210 {
12211
2/2
✓ Branch 0 taken 100864 times.
✓ Branch 1 taken 394 times.
101258 for(int32_t i = 0; i < NUMSCRIPTSITEMSPRITE; i++)
12212 {
12213 100864 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &itemspritescripts[i], zmeta_version);
12214
12215
1/2
✓ Branch 0 taken 100864 times.
✗ Branch 1 not taken.
100864 if (ret)
12216 {
12217 return qe_invalid;
12218 }
12219 100864 }
12220 394 }
12221
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 394 times.
526 if(s_version >=15)
12222 {
12223
2/2
✓ Branch 0 taken 201728 times.
✓ Branch 1 taken 394 times.
202122 for(int32_t i = 0; i < NUMSCRIPTSCOMBODATA; i++)
12224 {
12225 201728 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &comboscripts[i], zmeta_version);
12226
12227
1/2
✓ Branch 0 taken 201728 times.
✗ Branch 1 not taken.
201728 if (ret)
12228 {
12229 return qe_invalid;
12230 }
12231 201728 }
12232 394 }
12233
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 394 times.
526 if(s_version >19)
12234 {
12235 394 word numgenscripts = NUMSCRIPTSGENERIC;
12236
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if(!p_igetw(&numgenscripts,f))
12237 {
12238 return qe_invalid;
12239 }
12240
2/2
✓ Branch 0 taken 201728 times.
✓ Branch 1 taken 394 times.
202122 for(int32_t i = 0; i < numgenscripts; i++)
12241 {
12242 201728 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &genericscripts[i], zmeta_version);
12243
12244
1/2
✓ Branch 0 taken 201728 times.
✗ Branch 1 not taken.
201728 if (ret)
12245 {
12246 return qe_invalid;
12247 }
12248 201728 }
12249 394 }
12250
2/2
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 376 times.
526 if(s_version >21)
12251 {
12252 376 word numsubscripts = NUMSCRIPTSSUBSCREEN;
12253
1/2
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
376 if(!p_igetw(&numsubscripts,f))
12254 {
12255 return qe_invalid;
12256 }
12257
2/2
✓ Branch 0 taken 96256 times.
✓ Branch 1 taken 376 times.
96632 for(int32_t i = 0; i < numsubscripts; i++)
12258 {
12259 96256 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &subscreenscripts[i], zmeta_version);
12260
12261
1/2
✓ Branch 0 taken 96256 times.
✗ Branch 1 not taken.
96256 if (ret)
12262 {
12263 return qe_invalid;
12264 }
12265 96256 }
12266 376 }
12267 526 }
12268
12269
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 526 times.
526 if(s_version > 2)
12270 {
12271 int32_t bufsize;
12272 526 p_igetl(&bufsize, f);
12273
2/4
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 526 times.
526 if (bufsize < 0 || bufsize > 1024*1024*10)
12274 {
12275 // God help anyone storing more than 10MB of code in the script buffer.
12276 return qe_invalid;
12277 }
12278 526 char * buf = new char[bufsize+1];
12279 526 pfread(buf, bufsize, f);
12280 526 buf[bufsize]=0;
12281
12282
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 zScript = string(buf);
12283
12284
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 526 times.
526 delete[] buf;
12285 word numffcbindings;
12286 526 p_igetw(&numffcbindings, f);
12287
12288
2/2
✓ Branch 0 taken 6111 times.
✓ Branch 1 taken 526 times.
6637 for(int32_t i=0; i<numffcbindings; i++)
12289 {
12290 word id;
12291 6111 p_igetw(&id, f);
12292 6111 p_igetl(&bufsize, f);
12293
2/4
✓ Branch 0 taken 6111 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6111 times.
6111 if (bufsize < 0 || bufsize > 1024)
12294 return qe_invalid;
12295 6111 buf = new char[bufsize+1];
12296 6111 pfread(buf, bufsize, f);
12297 6111 buf[bufsize]=0;
12298
12299 //fix for buggy older saved quests -DD
12300
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6111 times.
6111 if(id < NUMSCRIPTFFC-1)
12301 6111 ffcmap[id].scriptname = buf;
12302
12303
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6111 times.
6111 delete[] buf;
12304 6111 }
12305
12306 word numglobalbindings;
12307 526 p_igetw(&numglobalbindings, f);
12308
12309
2/2
✓ Branch 0 taken 1278 times.
✓ Branch 1 taken 526 times.
1804 for(int32_t i=0; i<numglobalbindings; i++)
12310 {
12311 word id;
12312 1278 p_igetw(&id, f);
12313 1278 p_igetl(&bufsize, f);
12314
2/4
✓ Branch 0 taken 1278 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1278 times.
✗ Branch 3 not taken.
1278 if (bufsize < 0 || bufsize > 1024)
12315 return qe_invalid;
12316 1278 buf = new char[bufsize+1];
12317 1278 pfread(buf, bufsize, f);
12318 1278 buf[bufsize]=0;
12319
12320 // id in principle should be valid, since slot assignment cannot assign a global script to a bogus slot.
12321 // However, because of a corruption bug, some 2.50.x quests contain bogus entries in the global bindings table.
12322 // Ignore these. -DD
12323
3/4
✓ Branch 0 taken 1278 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 326 times.
✓ Branch 3 taken 952 times.
1278 if(id >= 0 && id < NUMSCRIPTGLOBAL)
12324 {
12325 //Disable old '~Continue's, they'd wreak havoc. Bit messy, apologies ~Joe
12326
1/2
✓ Branch 0 taken 952 times.
✗ Branch 1 not taken.
952 if(strcmp(buf,"~Continue") == 0)
12327 {
12328 globalmap[id].scriptname = "";
12329
12330 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12331 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD]->disable();
12332 }
12333 else
12334 {
12335 952 globalmap[id].scriptname = buf;
12336 }
12337 952 }
12338
12339
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1278 times.
1278 delete[] buf;
12340 1278 }
12341
12342
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 526 times.
526 if(s_version > 3)
12343 {
12344 word numitembindings;
12345 526 p_igetw(&numitembindings, f);
12346
12347
2/2
✓ Branch 0 taken 596 times.
✓ Branch 1 taken 526 times.
1122 for(int32_t i=0; i<numitembindings; i++)
12348 {
12349 word id;
12350 596 p_igetw(&id, f);
12351 596 p_igetl(&bufsize, f);
12352
2/4
✓ Branch 0 taken 596 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 596 times.
596 if (bufsize < 0 || bufsize > 1024)
12353 return qe_invalid;
12354 596 buf = new char[bufsize+1];
12355 596 pfread(buf, bufsize, f);
12356 596 buf[bufsize]=0;
12357
12358 //fix this too
12359
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 596 times.
596 if(id <NUMSCRIPTITEM-1)
12360 596 itemmap[id].scriptname = buf;
12361
12362
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 596 times.
596 delete[] buf;
12363 596 }
12364 526 }
12365 //(v9+)
12366
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 394 times.
526 if(s_version > 8)
12367 {
12368 //npc scripts
12369 word numnpcbindings;
12370 394 p_igetw(&numnpcbindings, f);
12371
12372
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 394 times.
424 for(int32_t i=0; i<numnpcbindings; i++)
12373 {
12374 word id;
12375 30 p_igetw(&id, f);
12376 30 p_igetl(&bufsize, f);
12377
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 if (bufsize < 0 || bufsize > 1024)
12378 return qe_invalid;
12379 30 buf = new char[bufsize+1];
12380 30 pfread(buf, bufsize, f);
12381 30 buf[bufsize]=0;
12382
12383 //fix this too
12384
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if(id <NUMSCRIPTGUYS-1)
12385 30 npcmap[id].scriptname = buf;
12386
12387
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 delete[] buf;
12388 30 }
12389 //lweapon
12390 word numlwpnbindings;
12391 394 p_igetw(&numlwpnbindings, f);
12392
12393
2/2
✓ Branch 0 taken 185 times.
✓ Branch 1 taken 394 times.
579 for(int32_t i=0; i<numlwpnbindings; i++)
12394 {
12395 word id;
12396 185 p_igetw(&id, f);
12397 185 p_igetl(&bufsize, f);
12398
2/4
✓ Branch 0 taken 185 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 185 times.
✗ Branch 3 not taken.
185 if (bufsize < 0 || bufsize > 1024)
12399 return qe_invalid;
12400 185 buf = new char[bufsize+1];
12401 185 pfread(buf, bufsize, f);
12402 185 buf[bufsize]=0;
12403
12404 //fix this too
12405
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 185 times.
185 if(id <NUMSCRIPTWEAPONS-1)
12406 185 lwpnmap[id].scriptname = buf;
12407
12408
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 185 times.
185 delete[] buf;
12409 185 }
12410 //eweapon
12411 word numewpnbindings;
12412 394 p_igetw(&numewpnbindings, f);
12413
12414
2/2
✓ Branch 0 taken 251 times.
✓ Branch 1 taken 394 times.
645 for(int32_t i=0; i<numewpnbindings; i++)
12415 {
12416 word id;
12417 251 p_igetw(&id, f);
12418 251 p_igetl(&bufsize, f);
12419
2/4
✓ Branch 0 taken 251 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 251 times.
✗ Branch 3 not taken.
251 if (bufsize < 0 || bufsize > 1024)
12420 return qe_invalid;
12421 251 buf = new char[bufsize+1];
12422 251 pfread(buf, bufsize, f);
12423 251 buf[bufsize]=0;
12424
12425 //fix this too
12426
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 251 times.
251 if(id <NUMSCRIPTWEAPONS-1)
12427 251 ewpnmap[id].scriptname = buf;
12428
12429
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 251 times.
251 delete[] buf;
12430 251 }
12431 //hero
12432 word numherobindings;
12433 394 p_igetw(&numherobindings, f);
12434
12435
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 394 times.
412 for(int32_t i=0; i<numherobindings; i++)
12436 {
12437 word id;
12438 18 p_igetw(&id, f);
12439 18 p_igetl(&bufsize, f);
12440
2/4
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 18 times.
18 if (bufsize < 0 || bufsize > 1024)
12441 return qe_invalid;
12442 18 buf = new char[bufsize+1];
12443 18 pfread(buf, bufsize, f);
12444 18 buf[bufsize]=0;
12445
12446 //fix this too
12447
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if(id <NUMSCRIPTPLAYER-1)
12448 18 playermap[id].scriptname = buf;
12449
12450
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 delete[] buf;
12451 18 }
12452 //dmaps
12453 word numdmapbindings;
12454 394 p_igetw(&numdmapbindings, f);
12455
12456
2/2
✓ Branch 0 taken 245 times.
✓ Branch 1 taken 394 times.
639 for(int32_t i=0; i<numdmapbindings; i++)
12457 {
12458 word id;
12459 245 p_igetw(&id, f);
12460 245 p_igetl(&bufsize, f);
12461
2/4
✓ Branch 0 taken 245 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 245 times.
✗ Branch 3 not taken.
245 if (bufsize < 0 || bufsize > 1024)
12462 return qe_invalid;
12463 245 buf = new char[bufsize+1];
12464 245 pfread(buf, bufsize, f);
12465 245 buf[bufsize]=0;
12466
12467 //fix this too
12468
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 245 times.
245 if(id <NUMSCRIPTSDMAP-1)
12469 245 dmapmap[id].scriptname = buf;
12470
12471
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 245 times.
245 delete[] buf;
12472 245 }
12473 //screen
12474 word numscreenbindings;
12475 394 p_igetw(&numscreenbindings, f);
12476
12477
2/2
✓ Branch 0 taken 273 times.
✓ Branch 1 taken 394 times.
667 for(int32_t i=0; i<numscreenbindings; i++)
12478 {
12479 word id;
12480 273 p_igetw(&id, f);
12481 273 p_igetl(&bufsize, f);
12482
2/4
✓ Branch 0 taken 273 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 273 times.
✗ Branch 3 not taken.
273 if (bufsize < 0 || bufsize > 1024)
12483 return qe_invalid;
12484 273 buf = new char[bufsize+1];
12485 273 pfread(buf, bufsize, f);
12486 273 buf[bufsize]=0;
12487
12488 //fix this too
12489
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 273 times.
273 if(id <NUMSCRIPTSDMAP-1)
12490 273 screenmap[id].scriptname = buf;
12491
12492
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 273 times.
273 delete[] buf;
12493 273 }
12494 394 }
12495
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 394 times.
526 if(s_version > 11)
12496 {
12497 word numspritebindings;
12498 394 p_igetw(&numspritebindings, f);
12499
12500
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 394 times.
433 for(int32_t i=0; i<numspritebindings; i++)
12501 {
12502 word id;
12503 39 p_igetw(&id, f);
12504 39 p_igetl(&bufsize, f);
12505
2/4
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
39 if (bufsize < 0 || bufsize > 1024)
12506 return qe_invalid;
12507 39 buf = new char[bufsize+1];
12508 39 pfread(buf, bufsize, f);
12509 39 buf[bufsize]=0;
12510
12511 //fix this too
12512
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39 times.
39 if(id <NUMSCRIPTSDMAP-1)
12513 39 itemspritemap[id].scriptname = buf;
12514
12515
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39 times.
39 delete[] buf;
12516 39 }
12517 394 }
12518
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 394 times.
526 if(s_version >= 15)
12519 {
12520 word numcombobindings;
12521 394 p_igetw(&numcombobindings, f);
12522
12523
2/2
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 394 times.
515 for(int32_t i=0; i<numcombobindings; i++)
12524 {
12525 word id;
12526 121 p_igetw(&id, f);
12527 121 p_igetl(&bufsize, f);
12528
2/4
✓ Branch 0 taken 121 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 121 times.
121 if (bufsize < 0 || bufsize > 1024)
12529 return qe_invalid;
12530 121 buf = new char[bufsize+1];
12531 121 pfread(buf, bufsize, f);
12532 121 buf[bufsize]=0;
12533
12534 //fix this too
12535
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 121 times.
121 if(id <NUMSCRIPTSCOMBODATA-1)
12536 121 comboscriptmap[id].scriptname = buf;
12537
12538
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 121 times.
121 delete[] buf;
12539 121 }
12540 394 }
12541
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 394 times.
526 if(s_version > 19)
12542 {
12543 word numgenericbindings;
12544 394 p_igetw(&numgenericbindings, f);
12545
12546
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 394 times.
477 for(int32_t i=0; i<numgenericbindings; i++)
12547 {
12548 word id;
12549 83 p_igetw(&id, f);
12550 83 p_igetl(&bufsize, f);
12551
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 83 times.
83 if (bufsize < 0 || bufsize > 1024)
12552 return qe_invalid;
12553 83 buf = new char[bufsize+1];
12554 83 pfread(buf, bufsize, f);
12555 83 buf[bufsize]=0;
12556
12557 //fix this too
12558
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 83 times.
83 if(id <NUMSCRIPTSGENERIC-1)
12559 83 genericmap[id].scriptname = buf;
12560
12561
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 83 times.
83 delete[] buf;
12562 83 }
12563 394 }
12564
2/2
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 376 times.
526 if(s_version > 21)
12565 {
12566 word numsubscreenbindings;
12567 376 p_igetw(&numsubscreenbindings, f);
12568
12569
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 376 times.
381 for(int32_t i=0; i<numsubscreenbindings; i++)
12570 {
12571 word id;
12572 5 p_igetw(&id, f);
12573 5 p_igetl(&bufsize, f);
12574
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
5 if (bufsize < 0 || bufsize > 1024)
12575 return qe_invalid;
12576 5 buf = new char[bufsize+1];
12577 5 pfread(buf, bufsize, f);
12578 5 buf[bufsize]=0;
12579
12580 //fix this too
12581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(id <NUMSCRIPTSSUBSCREEN-1)
12582 5 subscreenmap[id].scriptname = buf;
12583
12584
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 delete[] buf;
12585 5 }
12586 376 }
12587 526 }
12588
12589 // Set ZScriptVersion to the value encoded in the script's meta.ffscript_v.
12590 // This is only updated when the scripts have been recompiled.
12591 // They should all match each other.
12592 526 std::optional<word> zscript_version;
12593
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 394 times.
526 if (s_version >= 16)
12594 {
12595
2/2
✓ Branch 0 taken 393 times.
✓ Branch 1 taken 4416 times.
4809 for (auto script : read_scripts)
12596 {
12597
3/4
✓ Branch 0 taken 4415 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4415 times.
4416 if (script->meta.ffscript_v == 0 || script->meta.ffscript_v > s_version)
12598 1 break;
12599
12600
2/2
✓ Branch 0 taken 4029 times.
✓ Branch 1 taken 386 times.
4415 if (!zscript_version.has_value())
12601 {
12602 386 zscript_version = script->meta.ffscript_v;
12603 386 continue;
12604 }
12605
12606
1/2
✓ Branch 0 taken 4029 times.
✗ Branch 1 not taken.
4029 if (zscript_version.value() != script->meta.ffscript_v)
12607 {
12608 zscript_version.reset();
12609 break;
12610 }
12611 }
12612
12613
2/2
✓ Branch 0 taken 386 times.
✓ Branch 1 taken 8 times.
394 if (!zscript_version.has_value())
12614 8 al_trace("WARNING: Setting zscript version to section version as fallback.\n");
12615 394 }
12616 526 setZScriptVersion(zscript_version.value_or(s_version));
12617 526 read_scripts.clear();
12618
12619 526 return 0;
12620 526 }
12621
12622 588 void reset_scripts()
12623 {
12624 #ifdef IS_PLAYER
12625 // We can't modify the script data while jit threads are possibly compiling them.
12626 void jit_shutdown();
12627 580 jit_shutdown();
12628 #endif
12629
12630
2/2
✓ Branch 0 taken 301056 times.
✓ Branch 1 taken 588 times.
301644 for(int32_t i=0; i<NUMSCRIPTSGENERIC; i++)
12631 {
12632
1/2
✓ Branch 0 taken 301056 times.
✗ Branch 1 not taken.
301056 if (genericscripts[i]!=NULL) genericscripts[i]->disable();
12633 else genericscripts[i] = new script_data({ScriptType::Generic, i});
12634 301056 }
12635
12636
2/2
✓ Branch 0 taken 301056 times.
✓ Branch 1 taken 588 times.
301644 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
12637 {
12638
1/2
✓ Branch 0 taken 301056 times.
✗ Branch 1 not taken.
301056 if (ffscripts[i])
12639 301056 ffscripts[i]->disable();
12640 else
12641 ffscripts[i] = new script_data(ScriptType::FFC, i);
12642 301056 }
12643
12644
2/2
✓ Branch 0 taken 150528 times.
✓ Branch 1 taken 588 times.
151116 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
12645 {
12646
1/2
✓ Branch 0 taken 150528 times.
✗ Branch 1 not taken.
150528 if (itemscripts[i])
12647 150528 itemscripts[i]->disable();
12648 else
12649 itemscripts[i] = new script_data(ScriptType::Item, i);
12650 150528 }
12651
12652
2/2
✓ Branch 0 taken 150528 times.
✓ Branch 1 taken 588 times.
151116 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
12653 {
12654
1/2
✓ Branch 0 taken 150528 times.
✗ Branch 1 not taken.
150528 if (guyscripts[i])
12655 150528 guyscripts[i]->disable();
12656 else
12657 guyscripts[i] = new script_data(ScriptType::NPC, i);
12658 150528 }
12659
12660
2/2
✓ Branch 0 taken 150528 times.
✓ Branch 1 taken 588 times.
151116 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
12661 {
12662
1/2
✓ Branch 0 taken 150528 times.
✗ Branch 1 not taken.
150528 if (screenscripts[i])
12663 150528 screenscripts[i]->disable();
12664 else
12665 screenscripts[i] = new script_data(ScriptType::Screen, i);
12666 150528 }
12667
12668
2/2
✓ Branch 0 taken 4704 times.
✓ Branch 1 taken 588 times.
5292 for(int32_t i=0; i<NUMSCRIPTGLOBAL; i++)
12669 {
12670
1/2
✓ Branch 0 taken 4704 times.
✗ Branch 1 not taken.
4704 if (globalscripts[i])
12671 4704 globalscripts[i]->disable();
12672 else
12673 globalscripts[i] = new script_data(ScriptType::Global, i);
12674 4704 }
12675
12676
2/2
✓ Branch 0 taken 2940 times.
✓ Branch 1 taken 588 times.
3528 for(int32_t i=0; i<NUMSCRIPTPLAYER; i++)
12677 {
12678
1/2
✓ Branch 0 taken 2940 times.
✗ Branch 1 not taken.
2940 if (playerscripts[i])
12679 2940 playerscripts[i]->disable();
12680 else
12681 playerscripts[i] = new script_data(ScriptType::Player, i);
12682 2940 }
12683
12684
2/2
✓ Branch 0 taken 150528 times.
✓ Branch 1 taken 588 times.
151116 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12685 {
12686
1/2
✓ Branch 0 taken 150528 times.
✗ Branch 1 not taken.
150528 if (lwpnscripts[i])
12687 150528 lwpnscripts[i]->disable();
12688 else
12689 lwpnscripts[i] = new script_data(ScriptType::Lwpn, i);
12690 150528 }
12691
2/2
✓ Branch 0 taken 150528 times.
✓ Branch 1 taken 588 times.
151116 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12692 {
12693
1/2
✓ Branch 0 taken 150528 times.
✗ Branch 1 not taken.
150528 if (ewpnscripts[i])
12694 150528 ewpnscripts[i]->disable();
12695 else
12696 ewpnscripts[i] = new script_data(ScriptType::Ewpn, i);
12697 150528 }
12698
12699
2/2
✓ Branch 0 taken 150528 times.
✓ Branch 1 taken 588 times.
151116 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
12700 {
12701
1/2
✓ Branch 0 taken 150528 times.
✗ Branch 1 not taken.
150528 if (dmapscripts[i])
12702 150528 dmapscripts[i]->disable();
12703 else
12704 dmapscripts[i] = new script_data(ScriptType::DMap, i);
12705 150528 }
12706
2/2
✓ Branch 0 taken 150528 times.
✓ Branch 1 taken 588 times.
151116 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
12707 {
12708
1/2
✓ Branch 0 taken 150528 times.
✗ Branch 1 not taken.
150528 if (itemspritescripts[i])
12709 150528 itemspritescripts[i]->disable();
12710 else
12711 itemspritescripts[i] = new script_data(ScriptType::ItemSprite, i);
12712 150528 }
12713
2/2
✓ Branch 0 taken 301056 times.
✓ Branch 1 taken 588 times.
301644 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
12714 {
12715
1/2
✓ Branch 0 taken 301056 times.
✗ Branch 1 not taken.
301056 if (comboscripts[i])
12716 301056 comboscripts[i]->disable();
12717 else
12718 comboscripts[i] = new script_data(ScriptType::Combo, i);
12719 301056 }
12720
2/2
✓ Branch 0 taken 150528 times.
✓ Branch 1 taken 588 times.
151116 for(int32_t i=0; i<NUMSCRIPTSSUBSCREEN; i++)
12721 {
12722
1/2
✓ Branch 0 taken 150528 times.
✗ Branch 1 not taken.
150528 if (subscreenscripts[i])
12723 150528 subscreenscripts[i]->disable();
12724 else
12725 subscreenscripts[i] = new script_data(ScriptType::EngineSubscreen, i);
12726 150528 }
12727 588 }
12728
12729 1717150 int32_t read_one_ffscript(PACKFILE *f, zquestheader *, int32_t script_index, word s_version, word , script_data **script, word zmeta_version)
12730 {
12731 // TODO: refactor to just take a script_data*
12732 ASSERT(*script);
12733
12734 //Please also update loadquest() when modifying this method -DD
12735 1717150 char b33[34] = {0};
12736 1717150 b33[33] = 0;
12737 1717150 ffscript temp_script;
12738 1717150 int32_t num_commands=1000;
12739
12740
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1717150 times.
1717150 if(s_version>=2)
12741 {
12742
2/4
✓ Branch 0 taken 1717150 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1717150 times.
✗ Branch 3 not taken.
1717150 if(!p_igetl(&num_commands,f))
12743 {
12744 return qe_invalid;
12745 }
12746 1717150 }
12747
12748 #ifdef ZC_FUZZ
12749 const int32_t command_limit = 300000;
12750 #else
12751 1717150 const int32_t command_limit = 10000000;
12752 #endif
12753
2/4
✓ Branch 0 taken 1717150 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1717150 times.
✗ Branch 3 not taken.
1717150 if (num_commands < 0 || num_commands > command_limit)
12754 {
12755 return qe_invalid;
12756 }
12757
12758
1/2
✓ Branch 0 taken 1717150 times.
✗ Branch 1 not taken.
1717150 (*script)->null_script(num_commands);
12759
12760
2/2
✓ Branch 0 taken 1513474 times.
✓ Branch 1 taken 203676 times.
1717150 if(s_version >= 16)
12761 {
12762
1/2
✓ Branch 0 taken 1513474 times.
✗ Branch 1 not taken.
1513474 zasm_meta temp_meta;
12763
12764
2/4
✓ Branch 0 taken 1513474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1513474 times.
✗ Branch 3 not taken.
1513474 if(!p_igetw(&(temp_meta.zasm_v),f))
12765 {
12766 return qe_invalid;
12767 }
12768
12769
2/4
✓ Branch 0 taken 1513474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1513474 times.
✗ Branch 3 not taken.
1513474 if(!p_igetw(&(temp_meta.meta_v),f))
12770 {
12771 return qe_invalid;
12772 }
12773
12774
2/4
✓ Branch 0 taken 1513474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1513474 times.
✗ Branch 3 not taken.
1513474 if(!p_igetw(&(temp_meta.ffscript_v),f))
12775 {
12776 return qe_invalid;
12777 }
12778
12779
2/4
✓ Branch 0 taken 1513474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1513474 times.
✗ Branch 3 not taken.
1513474 if(!p_getc(&(temp_meta.script_type),f))
12780 {
12781 return qe_invalid;
12782 }
12783
12784
2/2
✓ Branch 0 taken 12107792 times.
✓ Branch 1 taken 1513474 times.
13621266 for(int32_t q = 0; q < 8; ++q)
12785 {
12786
2/2
✓ Branch 0 taken 143880 times.
✓ Branch 1 taken 11963912 times.
12107792 if(zmeta_version < 3)
12787 {
12788
2/2
✓ Branch 0 taken 143880 times.
✓ Branch 1 taken 4748040 times.
4891920 for(int32_t c = 0; c < 33; ++c)
12789 {
12790
2/4
✓ Branch 0 taken 4748040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4748040 times.
✗ Branch 3 not taken.
4748040 if(!p_getc(&(b33[c]),f))
12791 {
12792 return qe_invalid;
12793 }
12794 4748040 }
12795
1/2
✓ Branch 0 taken 143880 times.
✗ Branch 1 not taken.
143880 temp_meta.run_idens[q].assign(b33);
12796 143880 }
12797 else
12798 {
12799
2/4
✓ Branch 0 taken 11963912 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11963912 times.
✗ Branch 3 not taken.
11963912 if(!p_getcstr(&temp_meta.run_idens[q],f))
12800 {
12801 return qe_invalid;
12802 }
12803 }
12804 12107792 }
12805
12806
2/2
✓ Branch 0 taken 1513474 times.
✓ Branch 1 taken 12107792 times.
13621266 for(int32_t q = 0; q < 8; ++q)
12807 {
12808
2/4
✓ Branch 0 taken 12107792 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12107792 times.
✗ Branch 3 not taken.
12107792 if(!p_getc(&(temp_meta.run_types[q]),f))
12809 {
12810 return qe_invalid;
12811 }
12812 12107792 }
12813
12814
2/4
✓ Branch 0 taken 1513474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1513474 times.
✗ Branch 3 not taken.
1513474 if(!p_getc(&(temp_meta.flags),f))
12815 {
12816 return qe_invalid;
12817 }
12818
12819
2/4
✓ Branch 0 taken 1513474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1513474 times.
✗ Branch 3 not taken.
1513474 if(!p_igetw(&(temp_meta.compiler_v1),f))
12820 {
12821 return qe_invalid;
12822 }
12823
12824
2/4
✓ Branch 0 taken 1513474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1513474 times.
✗ Branch 3 not taken.
1513474 if(!p_igetw(&(temp_meta.compiler_v2),f))
12825 {
12826 return qe_invalid;
12827 }
12828
12829
2/4
✓ Branch 0 taken 1513474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1513474 times.
✗ Branch 3 not taken.
1513474 if(!p_igetw(&(temp_meta.compiler_v3),f))
12830 {
12831 return qe_invalid;
12832 }
12833
12834
2/4
✓ Branch 0 taken 1513474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1513474 times.
✗ Branch 3 not taken.
1513474 if(!p_igetw(&(temp_meta.compiler_v4),f))
12835 {
12836 return qe_invalid;
12837 }
12838
12839
2/2
✓ Branch 0 taken 17985 times.
✓ Branch 1 taken 1495489 times.
1513474 if(zmeta_version == 2)
12840 {
12841
2/2
✓ Branch 0 taken 17985 times.
✓ Branch 1 taken 593505 times.
611490 for(int32_t c = 0; c < 33; ++c)
12842 {
12843
2/4
✓ Branch 0 taken 593505 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 593505 times.
✗ Branch 3 not taken.
593505 if(!p_getc(&b33[c],f))
12844 {
12845 return qe_invalid;
12846 }
12847 593505 }
12848
1/2
✓ Branch 0 taken 17985 times.
✗ Branch 1 not taken.
17985 temp_meta.script_name.assign(b33);
12849
12850
2/2
✓ Branch 0 taken 17985 times.
✓ Branch 1 taken 593505 times.
611490 for(int32_t c = 0; c < 33; ++c)
12851 {
12852
2/4
✓ Branch 0 taken 593505 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 593505 times.
✗ Branch 3 not taken.
593505 if(!p_getc(&b33[c],f))
12853 {
12854 return qe_invalid;
12855 }
12856 593505 }
12857
1/2
✓ Branch 0 taken 17985 times.
✗ Branch 1 not taken.
17985 temp_meta.author.assign(b33);
12858 17985 }
12859
1/2
✓ Branch 0 taken 1495489 times.
✗ Branch 1 not taken.
1495489 else if(zmeta_version > 2)
12860 {
12861
2/4
✓ Branch 0 taken 1495489 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1495489 times.
✗ Branch 3 not taken.
1495489 if(!p_getcstr(&temp_meta.script_name,f))
12862 return qe_invalid;
12863
2/4
✓ Branch 0 taken 1495489 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1495489 times.
✗ Branch 3 not taken.
1495489 if(!p_getcstr(&temp_meta.author,f))
12864 return qe_invalid;
12865 1495489 auto num_meta_attrib = (zmeta_version < 5 ? 4 : 10);
12866
2/2
✓ Branch 0 taken 14954890 times.
✓ Branch 1 taken 1495489 times.
16450379 for(auto q = 0; q < num_meta_attrib; ++q)
12867 {
12868
2/4
✓ Branch 0 taken 14954890 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14954890 times.
✗ Branch 3 not taken.
14954890 if(!p_getcstr(&temp_meta.attributes[q],f))
12869 return qe_invalid;
12870
2/4
✓ Branch 0 taken 14954890 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14954890 times.
✗ Branch 3 not taken.
14954890 if(!p_getwstr(&temp_meta.attributes_help[q],f))
12871 return qe_invalid;
12872 14954890 }
12873
2/2
✓ Branch 0 taken 11963912 times.
✓ Branch 1 taken 1495489 times.
13459401 for(auto q = 0; q < 8; ++q)
12874 {
12875
2/4
✓ Branch 0 taken 11963912 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11963912 times.
✗ Branch 3 not taken.
11963912 if(!p_getcstr(&temp_meta.attribytes[q],f))
12876 return qe_invalid;
12877
2/4
✓ Branch 0 taken 11963912 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11963912 times.
✗ Branch 3 not taken.
11963912 if(!p_getwstr(&temp_meta.attribytes_help[q],f))
12878 return qe_invalid;
12879 11963912 }
12880
2/2
✓ Branch 0 taken 11963912 times.
✓ Branch 1 taken 1495489 times.
13459401 for(auto q = 0; q < 8; ++q)
12881 {
12882
2/4
✓ Branch 0 taken 11963912 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11963912 times.
✗ Branch 3 not taken.
11963912 if(!p_getcstr(&temp_meta.attrishorts[q],f))
12883 return qe_invalid;
12884
2/4
✓ Branch 0 taken 11963912 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11963912 times.
✗ Branch 3 not taken.
11963912 if(!p_getwstr(&temp_meta.attrishorts_help[q],f))
12885 return qe_invalid;
12886 11963912 }
12887
2/2
✓ Branch 0 taken 23927824 times.
✓ Branch 1 taken 1495489 times.
25423313 for(auto q = 0; q < 16; ++q)
12888 {
12889
2/4
✓ Branch 0 taken 23927824 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23927824 times.
✗ Branch 3 not taken.
23927824 if(!p_getcstr(&temp_meta.usrflags[q],f))
12890 return qe_invalid;
12891
2/4
✓ Branch 0 taken 23927824 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23927824 times.
✗ Branch 3 not taken.
23927824 if(!p_getwstr(&temp_meta.usrflags_help[q],f))
12892 return qe_invalid;
12893 23927824 }
12894 1495489 }
12895
2/2
✓ Branch 0 taken 1495489 times.
✓ Branch 1 taken 17985 times.
1513474 if(zmeta_version > 3)
12896 {
12897
2/2
✓ Branch 0 taken 11963912 times.
✓ Branch 1 taken 1495489 times.
13459401 for(auto q = 0; q < 8; ++q)
12898 {
12899
2/4
✓ Branch 0 taken 11963912 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11963912 times.
✗ Branch 3 not taken.
11963912 if(!p_getcstr(&temp_meta.initd[q],f))
12900 return qe_invalid;
12901
2/4
✓ Branch 0 taken 11963912 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11963912 times.
✗ Branch 3 not taken.
11963912 if(!p_getwstr(&temp_meta.initd_help[q],f))
12902 return qe_invalid;
12903 11963912 }
12904
2/2
✓ Branch 0 taken 11963912 times.
✓ Branch 1 taken 1495489 times.
13459401 for(auto q = 0; q < 8; ++q)
12905 {
12906
2/4
✓ Branch 0 taken 11963912 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11963912 times.
✗ Branch 3 not taken.
11963912 if(!p_getc(&temp_meta.initd_type[q],f))
12907 return qe_invalid;
12908 11963912 }
12909 1495489 }
12910 else
12911 {
12912
2/2
✓ Branch 0 taken 143880 times.
✓ Branch 1 taken 17985 times.
161865 for(auto q = 0; q < 8; ++q)
12913 {
12914
1/2
✓ Branch 0 taken 143880 times.
✗ Branch 1 not taken.
143880 temp_meta.initd[q] = temp_meta.run_idens[q];
12915 143880 }
12916 }
12917
12918
1/2
✓ Branch 0 taken 1513474 times.
✗ Branch 1 not taken.
1513474 (*script)->meta = temp_meta;
12919
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1513474 times.
1513474 }
12920
12921
1/2
✓ Branch 0 taken 1717150 times.
✗ Branch 1 not taken.
1717150 temp_script.clear();
12922
1/2
✓ Branch 0 taken 63333815 times.
✗ Branch 1 not taken.
63333815 for(int32_t j=0; j<num_commands; j++)
12923 {
12924
2/4
✓ Branch 0 taken 63333815 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 63333815 times.
✗ Branch 3 not taken.
63333815 if(!p_igetw(&(temp_script.command),f))
12925 {
12926 return qe_invalid;
12927 }
12928
12929
2/2
✓ Branch 0 taken 1717150 times.
✓ Branch 1 taken 61616665 times.
63333815 if(temp_script.command == 0xFFFF)
12930 {
12931
1/2
✓ Branch 0 taken 1717150 times.
✗ Branch 1 not taken.
1717150 (*script)->zasm[j].clear();
12932 1717150 break;
12933 }
12934 else
12935 {
12936
2/4
✓ Branch 0 taken 61616665 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 61616665 times.
✗ Branch 3 not taken.
61616665 if(!p_igetl(&(temp_script.arg1),f))
12937 {
12938 return qe_invalid;
12939 }
12940
12941
2/4
✓ Branch 0 taken 61616665 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 61616665 times.
✗ Branch 3 not taken.
61616665 if(!p_igetl(&(temp_script.arg2),f))
12942 {
12943 return qe_invalid;
12944 }
12945
12946
2/2
✓ Branch 0 taken 2273821 times.
✓ Branch 1 taken 59342844 times.
61616665 if(s_version >= 24)
12947
2/4
✓ Branch 0 taken 2273821 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2273821 times.
✗ Branch 3 not taken.
2273821 if(!p_igetl(&(temp_script.arg3),f))
12948 return qe_invalid;
12949
12950
2/2
✓ Branch 0 taken 7007854 times.
✓ Branch 1 taken 54608811 times.
61616665 if(s_version >= 21)
12951 {
12952 7007854 uint32_t sz = 0;
12953
2/4
✓ Branch 0 taken 7007854 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7007854 times.
✗ Branch 3 not taken.
7007854 if(!p_igetl(&sz,f))
12954 {
12955 return qe_invalid;
12956 }
12957
2/2
✓ Branch 0 taken 30545 times.
✓ Branch 1 taken 6977309 times.
7007854 if(sz) //string found
12958 {
12959
1/2
✓ Branch 0 taken 30545 times.
✗ Branch 1 not taken.
30545 temp_script.strptr = new std::string();
12960 char dummy;
12961
2/2
✓ Branch 0 taken 1154177 times.
✓ Branch 1 taken 30545 times.
1184722 for(size_t q = 0; q < sz; ++q)
12962 {
12963
2/4
✓ Branch 0 taken 1154177 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1154177 times.
✗ Branch 3 not taken.
1154177 if(!p_getc(&dummy,f))
12964 {
12965 return qe_invalid;
12966 }
12967
1/2
✓ Branch 0 taken 1154177 times.
✗ Branch 1 not taken.
1154177 temp_script.strptr->push_back(dummy);
12968 1154177 }
12969 30545 }
12970
2/4
✓ Branch 0 taken 7007854 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7007854 times.
✗ Branch 3 not taken.
7007854 if(!p_igetl(&sz,f))
12971 {
12972 return qe_invalid;
12973 }
12974
2/2
✓ Branch 0 taken 2043 times.
✓ Branch 1 taken 7005811 times.
7007854 if(sz) //vector found
12975 {
12976
1/2
✓ Branch 0 taken 2043 times.
✗ Branch 1 not taken.
2043 temp_script.vecptr = new std::vector<int32_t>();
12977 int32_t dummy;
12978
2/2
✓ Branch 0 taken 12718 times.
✓ Branch 1 taken 2043 times.
14761 for(size_t q = 0; q < sz; ++q)
12979 {
12980
2/4
✓ Branch 0 taken 12718 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12718 times.
✗ Branch 3 not taken.
12718 if(!p_igetl(&dummy,f))
12981 {
12982 return qe_invalid;
12983 }
12984
1/2
✓ Branch 0 taken 12718 times.
✗ Branch 1 not taken.
12718 temp_script.vecptr->push_back(dummy);
12985 12718 }
12986 2043 }
12987 7007854 }
12988
12989
1/2
✓ Branch 0 taken 61616665 times.
✗ Branch 1 not taken.
61616665 temp_script.give((*script)->zasm[j]);
12990 }
12991
1/2
✓ Branch 0 taken 61616665 times.
✗ Branch 1 not taken.
61616665 temp_script.clear();
12992 61616665 }
12993
12994 // If the first command is unknown, invalidate the whole thing.
12995 // Saw this for https://www.purezc.net/index.php?page=quests&id=411 hero script 0
12996
3/4
✓ Branch 0 taken 1708425 times.
✓ Branch 1 taken 8725 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1708425 times.
1717150 if ((*script)->zasm[0].command >= NUMCOMMANDS && (*script)->zasm[0].command != 0xFFFF)
12997 {
12998 al_trace("Warning: found script with bad instruction, disabling script: %s %d\n", ScriptTypeToString((*script)->id.type), (*script)->id.index);
12999 (*script)->zasm[0].command = 0xFFFF;
13000 }
13001
13002
1/2
✓ Branch 0 taken 1717150 times.
✗ Branch 1 not taken.
1717150 (*script)->recalc_size();
13003
3/4
✓ Branch 0 taken 1717150 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8725 times.
✓ Branch 3 taken 1708425 times.
1717150 if ((*script)->valid())
13004
1/2
✓ Branch 0 taken 8725 times.
✗ Branch 1 not taken.
8725 read_scripts.push_back(*script);
13005
13006 1717150 return 0;
13007 1717150 }
13008
13009 extern SAMPLE customsfxdata[WAV_COUNT];
13010 extern uint8_t customsfxflag[WAV_COUNT>>3];
13011 extern int32_t sfxdat;
13012 extern DATAFILE *sfxdata;
13013 const char *old_sfx_string[Z35] =
13014 {
13015 "Arrow", "Sword beam", "Bomb blast", "Boomerang", "Subscreen cursor",
13016 "Shield is hit", "Item chime", "Roar (Dodongo, Gohma)", "Shutter", "Enemy dies",
13017 "Enemy is hit", "Low hearts warning", "Fire", "Ganon's fanfare", "Boss is hit", "Hammer",
13018 "Hookshot", "Message", "Player is hit", "Item fanfare", "Bomb placed", "Item pickup",
13019 "Refill", "Roar (Aquamentus, Gleeok, Ganon)", "Item pickup 2", "Ocean ambience",
13020 "Secret chime", "Player dies", "Stairs", "Sword", "Roar (Manhandla, Digdogger, Patra)",
13021 "Wand magic", "Whistle", "Zelda's fanfare", "Charging weapon", "Charging weapon 2",
13022 "Divine Fire", "Enemy falls from ceiling", "Divine Escape", "Fireball", "Tall Grass slashed",
13023 "Pound pounded", "Hover Boots", "Ice magic", "Jump", "Lens of Truth off", "Lens of Truth on",
13024 "Divine Protection shield", "Divine Protection 2", "Push block", "Rock", "Spell rocket down",
13025 "Spell rocket up", "Sword spin attack", "Splash", "Summon magic", "Sword tapping",
13026 "Sword tapping (secret)", "Whistle whirlwind", "Cane of Byrna orbit"
13027 };
13028 char *sfx_string[WAV_COUNT];
13029
13030 526 int32_t readsfx(PACKFILE *f, zquestheader *Header)
13031 {
13032 //these are here to bypass compiler warnings about unused arguments
13033 526 Header=Header;
13034
13035 int32_t dummy;
13036 526 word s_version=0, s_cversion=0;
13037 //int32_t ret;
13038 526 SAMPLE temp_sample = {};
13039 526 temp_sample.loop_start=0;
13040 526 temp_sample.loop_end=0;
13041 526 temp_sample.param=0;
13042
13043 //section version info
13044
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 526 times.
526 if(!p_igetw(&s_version,f))
13045 {
13046 return qe_invalid;
13047 }
13048
13049 526 FFCore.quest_format[vSFX] = s_version;
13050
13051 //al_trace("SFX version %d\n", s_version);
13052
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 if(!p_igetw(&s_cversion,f))
13053 {
13054 return qe_invalid;
13055 }
13056
13057 //section size
13058
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 if(!p_igetl(&dummy,f))
13059 {
13060 return qe_invalid;
13061 }
13062
13063 /* HIGHLY UNORTHODOX UPDATING THING, by L
13064 * This fixes quests made before revision 411 (such as the 'Lost Isle Build'),
13065 * where the meaning of GOTOLESS changed. It also coincided with V_SFX
13066 * changing from 1 to 2.
13067 */
13068
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 if(s_version < 2)
13069 set_qr(qr_GOTOLESSNOTEQUAL,1);
13070
13071 /* End highly unorthodox updating thing */
13072
13073 526 int32_t wavcount = WAV_COUNT;
13074
13075
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 if(s_version < 6)
13076 wavcount = 128;
13077
13078 uint8_t tempflag[WAV_COUNT>>3];
13079
13080
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 526 times.
526 if(s_version < 4)
13081 {
13082 memset(tempflag, 0xFF, WAV_COUNT>>3);
13083 }
13084 else
13085 {
13086
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 if(s_version < 6)
13087 memset(tempflag, 0, WAV_COUNT>>3);
13088
13089
2/2
✓ Branch 0 taken 16832 times.
✓ Branch 1 taken 526 times.
17358 for(int32_t i=0; i<(wavcount>>3); i++)
13090 {
13091 16832 p_getc(&tempflag[i], f);
13092 16832 }
13093
13094 }
13095
13096
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 if(s_version>4)
13097 {
13098
2/2
✓ Branch 0 taken 134130 times.
✓ Branch 1 taken 526 times.
134656 for(int32_t i=1; i<WAV_COUNT; i++)
13099 {
13100 134130 sprintf(sfx_string[i],"s%03d",i);
13101
13102
2/2
✓ Branch 0 taken 102570 times.
✓ Branch 1 taken 31560 times.
134130 if((i<Z35))
13103 31560 strcpy(sfx_string[i], old_sfx_string[i-1]);
13104
13105
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 134130 times.
134130 if(i>=wavcount)
13106 continue;
13107
2/2
✓ Branch 0 taken 30739 times.
✓ Branch 1 taken 103391 times.
134130 if(get_bit(tempflag, i-1))
13108 {
13109 char tempname[36];
13110
13111
1/2
✓ Branch 0 taken 30739 times.
✗ Branch 1 not taken.
30739 if(!pfread(tempname, 36, f))
13112 {
13113 return qe_invalid;
13114 }
13115
13116 30739 sfx_string[i][0] = '\0';
13117 30739 strncat(sfx_string[i], tempname, 36 - 1);
13118 30739 }
13119 else
13120 {
13121 103391 sprintf(sfx_string[i],"s%03d",i);
13122
13123
2/2
✓ Branch 0 taken 96269 times.
✓ Branch 1 taken 7122 times.
103391 if(i<Z35)
13124 7122 strcpy(sfx_string[i], old_sfx_string[i-1]);
13125 103391 sfx_string[i][35] = 0; //Force NULL Termination
13126 }
13127 134130 }
13128 526 }
13129 else
13130 {
13131 for(int32_t i=1; i<WAV_COUNT; i++)
13132 {
13133 sprintf(sfx_string[i],"s%03d",i);
13134
13135 if(i<Z35)
13136 strcpy(sfx_string[i], old_sfx_string[i-1]);
13137 }
13138 }
13139
13140 //finally... section data
13141
2/2
✓ Branch 0 taken 134130 times.
✓ Branch 1 taken 526 times.
134656 for(int32_t i=1; i<wavcount; i++)
13142 {
13143
2/2
✓ Branch 0 taken 30739 times.
✓ Branch 1 taken 103391 times.
134130 if(get_bit(tempflag, i-1))
13144 {
13145
13146
1/2
✓ Branch 0 taken 30739 times.
✗ Branch 1 not taken.
30739 if(!p_igetl(&dummy,f))
13147 {
13148 return qe_invalid;
13149 }
13150
13151 30739 (temp_sample.bits) = dummy;
13152
13153
1/2
✓ Branch 0 taken 30739 times.
✗ Branch 1 not taken.
30739 if(!p_igetl(&dummy,f))
13154 {
13155 return qe_invalid;
13156 }
13157
13158 30739 (temp_sample.stereo) = dummy;
13159
13160
1/2
✓ Branch 0 taken 30739 times.
✗ Branch 1 not taken.
30739 if(!p_igetl(&dummy,f))
13161 {
13162 return qe_invalid;
13163 }
13164
13165 30739 (temp_sample.freq) = dummy;
13166
13167
1/2
✓ Branch 0 taken 30739 times.
✗ Branch 1 not taken.
30739 if(!p_igetl(&dummy,f))
13168 {
13169 return qe_invalid;
13170 }
13171
13172 30739 (temp_sample.priority) = dummy;
13173
13174
1/2
✓ Branch 0 taken 30739 times.
✗ Branch 1 not taken.
30739 if(!p_igetl(&(temp_sample.len),f))
13175 {
13176 return qe_invalid;
13177 }
13178
13179
1/2
✓ Branch 0 taken 30739 times.
✗ Branch 1 not taken.
30739 if(!p_igetl(&(temp_sample.loop_start),f))
13180 {
13181 return qe_invalid;
13182 }
13183
13184
1/2
✓ Branch 0 taken 30739 times.
✗ Branch 1 not taken.
30739 if(!p_igetl(&(temp_sample.loop_end),f))
13185 {
13186 return qe_invalid;
13187 }
13188
13189
1/2
✓ Branch 0 taken 30739 times.
✗ Branch 1 not taken.
30739 if(!p_igetl(&(temp_sample.param),f))
13190 {
13191 return qe_invalid;
13192 }
13193
13194 // al_trace("F%i: L%i\n",i,temp_sample.len);
13195 // temp_sample.data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13196 30739 auto len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13197
2/4
✓ Branch 0 taken 30739 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 30739 times.
30739 if (len < 0 || len > 10000000)
13198 {
13199 return qe_invalid;
13200 }
13201 30739 temp_sample.data = calloc(len,1);
13202
13203
1/2
✓ Branch 0 taken 30739 times.
✗ Branch 1 not taken.
30739 if(s_version < 3)
13204 len = (temp_sample.bits==8?1:2)*temp_sample.len;
13205
13206 //old-style, non-portable loading (Bad Allegro! Bad!!) -DD
13207
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30739 times.
30739 if(s_version < 2)
13208 {
13209 if(!pfread(temp_sample.data, len,f))
13210 {
13211 return qe_invalid;
13212 }
13213 }
13214 else
13215 {
13216 //re-endianfy the data
13217 30739 int32_t wordstoread = len / sizeof(word);
13218
13219
2/2
✓ Branch 0 taken 828140060 times.
✓ Branch 1 taken 30739 times.
828170799 for(int32_t j=0; j<wordstoread; j++)
13220 {
13221 word temp;
13222
13223
1/2
✓ Branch 0 taken 828140060 times.
✗ Branch 1 not taken.
828140060 if(!p_igetw(&temp, f))
13224 {
13225 return qe_invalid;
13226 }
13227
13228 828140060 ((word *)temp_sample.data)[j] = temp;
13229 828140060 }
13230 }
13231 30739 }
13232
2/2
✓ Branch 0 taken 7122 times.
✓ Branch 1 taken 96269 times.
103391 else if(i < Z35)
13233 {
13234 7122 SAMPLE* datsamp = (SAMPLE*)(sfxdata[i].dat);
13235 7122 memcpy(&temp_sample, datsamp, sizeof(SAMPLE));
13236 7122 set_bit(tempflag, i-1, 1);
13237 7122 int32_t len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13238 7122 temp_sample.data = calloc(len,1);
13239 7122 memcpy(temp_sample.data, datsamp->data, len);
13240 7122 }
13241 96269 else continue;
13242
13243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37861 times.
37861 if(customsfxdata[i].data!=NULL)
13244 {
13245 // delete [] customsfxdata[i].data;
13246 37861 free(customsfxdata[i].data);
13247 37861 }
13248
13249 // customsfxdata[i].data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13250 37861 int32_t len2 = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13251 37861 customsfxdata[i].data = calloc(len2,1);
13252 37861 customsfxdata[i].bits = temp_sample.bits;
13253 37861 customsfxdata[i].stereo = temp_sample.stereo;
13254 37861 customsfxdata[i].freq = temp_sample.freq;
13255 37861 customsfxdata[i].priority = temp_sample.priority;
13256 37861 customsfxdata[i].len = temp_sample.len;
13257 37861 customsfxdata[i].loop_start = temp_sample.loop_start;
13258 37861 customsfxdata[i].loop_end = temp_sample.loop_end;
13259 37861 customsfxdata[i].param = temp_sample.param;
13260 37861 int32_t cpylen = len2;
13261
13262
1/2
✓ Branch 0 taken 37861 times.
✗ Branch 1 not taken.
37861 if(s_version<3)
13263 {
13264 cpylen = (temp_sample.bits==8?1:2)*temp_sample.len;
13265 al_trace("WARNING: Quest SFX %d is in stereo, and may be corrupt.\n",i);
13266 }
13267
13268 37861 memcpy(customsfxdata[i].data,temp_sample.data,cpylen);
13269
13270 37861 free(temp_sample.data);
13271 37861 }
13272
13273 526 memcpy(customsfxflag, tempflag, WAV_COUNT>>3);
13274
13275 526 sfxdat=0;
13276 526 return 0;
13277 526 }
13278
13279 588 void setupsfx()
13280 {
13281
2/2
✓ Branch 0 taken 149940 times.
✓ Branch 1 taken 588 times.
150528 for(int32_t i=1; i<WAV_COUNT; i++)
13282 {
13283 149940 sprintf(sfx_string[i],"s%03d",i);
13284
13285
2/2
✓ Branch 0 taken 114660 times.
✓ Branch 1 taken 35280 times.
149940 if(i<Z35)
13286 {
13287 35280 strcpy(sfx_string[i], old_sfx_string[i-1]);
13288 35280 }
13289
13290 149940 memset(customsfxflag, 0, WAV_COUNT>>3);
13291
13292 149940 int32_t j=i;
13293
13294
2/2
✓ Branch 0 taken 35868 times.
✓ Branch 1 taken 114072 times.
149940 if(i>Z35)
13295 {
13296 114072 i=Z35;
13297 114072 }
13298
13299 149940 SAMPLE *temp_sample = (SAMPLE *)sfxdata[i].dat;
13300
13301
2/2
✓ Branch 0 taken 78285 times.
✓ Branch 1 taken 71655 times.
149940 if(customsfxdata[j].data!=NULL)
13302 {
13303 // delete [] customsfxdata[j].data;
13304 71655 free(customsfxdata[j].data);
13305 71655 }
13306
13307 // customsfxdata[j].data = new byte[(temp_sample->bits==8?1:2)*temp_sample->len];
13308 149940 customsfxdata[j].data = calloc((temp_sample->bits==8?1:2)*(temp_sample->stereo == 0 ? 1 : 2)*temp_sample->len,1);
13309 149940 customsfxdata[j].bits = temp_sample->bits;
13310 149940 customsfxdata[j].stereo = temp_sample->stereo;
13311 149940 customsfxdata[j].freq = temp_sample->freq;
13312 149940 customsfxdata[j].priority = temp_sample->priority;
13313 149940 customsfxdata[j].len = temp_sample->len;
13314 149940 customsfxdata[j].loop_start = temp_sample->loop_start;
13315 149940 customsfxdata[j].loop_end = temp_sample->loop_end;
13316 149940 customsfxdata[j].param = temp_sample->param;
13317 149940 memcpy(customsfxdata[j].data, (temp_sample->data), (temp_sample->bits==8?1:2)*(temp_sample->stereo==0 ? 1 : 2)*temp_sample->len);
13318 149940 i=j;
13319 149940 }
13320 588 }
13321
13322 extern char *guy_string[eMAXGUYS];
13323 extern const char *old_guy_string[OLDMAXGUYS];
13324
13325 588 int32_t readguys(PACKFILE *f, zquestheader *Header)
13326 {
13327
2/2
✓ Branch 0 taken 565 times.
✓ Branch 1 taken 23 times.
588 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_guys);
13328
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 588 times.
588 if (should_skip) return 0;
13329
13330 dword dummy;
13331 word guy_cversion;
13332 588 word guyversion=0;
13333
13334
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 565 times.
588 if(Header->zelda_version >= 0x193)
13335 {
13336 //section version info
13337
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 if(!p_igetw(&guyversion,f))
13338 {
13339 return qe_invalid;
13340 }
13341
13342 565 FFCore.quest_format[vGuys] = guyversion;
13343
13344 //al_trace("Guys version %d\n", guyversion);
13345
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 if(!p_igetw(&guy_cversion,f))
13346 {
13347 return qe_invalid;
13348 }
13349 565 al_trace("Guy CVersion is: %d\n", guy_cversion);
13350 //section size
13351
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 if(!p_igetl(&dummy,f))
13352 {
13353 return qe_invalid;
13354 }
13355 565 }
13356
13357
2/2
✓ Branch 0 taken 526 times.
✓ Branch 1 taken 62 times.
588 if(guyversion > 3)
13358 {
13359
2/2
✓ Branch 0 taken 269312 times.
✓ Branch 1 taken 526 times.
269838 for(int32_t i=0; i<MAXGUYS; i++)
13360 {
13361 char tempname[64];
13362
13363 // rev. 1511 : guyversion = 23. upped to 512 editable enemies. -Gleeok
13364 // if guyversion < 23 then there is only 256 enemies in the packfile, so default the rest.
13365
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 269312 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
269312 if(guyversion < 23 && i >= OLDBETAMAXGUYS)
13366 {
13367 memset(tempname, 0, sizeof(char)*64);
13368 sprintf(tempname, "e%03d", i);
13369 strcpy(guy_string[i], tempname);
13370
13371 continue;
13372 }
13373
13374
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(!pfread(tempname, 64, f))
13375 {
13376 return qe_invalid;
13377 }
13378
13379 // Don't retain names of uneditable enemy entries!
13380 // for version upgrade to 2.5
13381
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 269312 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
269312 if(guyversion < 23 && i >= 177)
13382 {
13383 // some of the older builds have names such as 'zz123',
13384 // (this order gets messed up with some eXXX and some zzXXX)
13385 // so let's update to the newer naming convection. -Gleeok
13386 char tmpbuf[64];
13387 memset(tmpbuf, 0, sizeof(char)*64);
13388 sprintf(tmpbuf, "zz%03d", i);
13389
13390 if(memcmp(tempname, tmpbuf, size_t(5)) == 0)
13391 {
13392 memset(tempname, 0, sizeof(char)*64);
13393 sprintf(tempname, "e%03d", i);
13394 }
13395 }
13396
13397
6/6
✓ Branch 0 taken 93102 times.
✓ Branch 1 taken 176210 times.
✓ Branch 2 taken 88368 times.
✓ Branch 3 taken 4734 times.
✓ Branch 4 taken 81414 times.
✓ Branch 5 taken 6954 times.
269312 if(i >= OLDMAXGUYS || strlen(tempname)<1 || tempname[strlen(tempname)-1]!=' ')
13398 {
13399 262358 guy_string[i][0] = '\0';
13400 262358 strncat(guy_string[i], tempname, 64 - 1);
13401 262358 }
13402 else
13403 {
13404 6954 strcpy(guy_string[i],old_guy_string[i]);
13405 }
13406 269312 }
13407 526 }
13408 else
13409 {
13410
2/2
✓ Branch 0 taken 31744 times.
✓ Branch 1 taken 62 times.
31806 for(int32_t i=0; i<eMAXGUYS; i++)
13411 {
13412 31744 sprintf(guy_string[i],"zz%03d",i);
13413 31744 }
13414
13415
2/2
✓ Branch 0 taken 10974 times.
✓ Branch 1 taken 62 times.
11036 for(int32_t i=0; i<OLDMAXGUYS; i++)
13416 {
13417 10974 strcpy(guy_string[i],old_guy_string[i]);
13418 10974 }
13419 }
13420
13421
13422 //finally... section data
13423 588 init_guys(guyversion); //using default data for now...
13424
13425 // Goriya guy fix
13426
3/6
✓ Branch 0 taken 526 times.
✓ Branch 1 taken 62 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 526 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
588 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<7)))
13427 {
13428
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 40 times.
62 if(get_qr(qr_NEWENEMYTILES))
13429 {
13430 40 guysbuf[gGORIYA].tile=130;
13431 40 guysbuf[gGORIYA].e_tile=130;
13432 40 }
13433 62 }
13434
13435
2/2
✓ Branch 0 taken 565 times.
✓ Branch 1 taken 23 times.
588 if(Header->zelda_version < 0x193)
13436 {
13437
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 5 times.
23 if(get_bit(deprecated_rules,46))
13438 {
13439 5 guysbuf[eDODONGO].cset=14;
13440 5 guysbuf[eDODONGO].bosspal=spDIG;
13441 5 }
13442 23 }
13443 // Not sure when this first changed, but it's necessary for 2.10, at least
13444 // @TODO: @BUG:1.92 - 1.84? Figure this out exactly for the final 2.50 release.
13445 //2.10 Fixes
13446
3/6
✓ Branch 0 taken 526 times.
✓ Branch 1 taken 62 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 526 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
588 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<18)))
13447 {
13448 62 guysbuf[eWWIZ].editorflags |= ENEMY_FLAG5;
13449 62 guysbuf[eMOLDORM].editorflags |= ENEMY_FLAG6;
13450 62 guysbuf[eMANHAN].editorflags |= ENEMY_FLAG6;
13451 62 guysbuf[eCENT1].misc3 = 1;
13452 62 guysbuf[eCENT2].misc3 = 1;
13453 62 }
13454
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 588 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
588 if((Header->zelda_version <= 0x255) || (Header->zelda_version == 0x255 && Header->build < 47) )
13455 {
13456 588 guysbuf[eWPOLSV].defense[edefWhistle] = ed1HKO;
13457 588 }
13458
2/2
✓ Branch 0 taken 526 times.
✓ Branch 1 taken 62 times.
588 if(Header->zelda_version <= 0x210)
13459 {
13460 62 guysbuf[eGLEEOK1F].misc6 = 16;
13461 62 guysbuf[eGLEEOK2F].misc6 = 16;
13462 62 guysbuf[eGLEEOK3F].misc6 = 16;
13463 62 guysbuf[eGLEEOK4F].misc6 = 16;
13464
13465 62 guysbuf[eWIZ1].misc4 = 1; //only set the enemy that needs backward compat, not all of them.
13466 62 guysbuf[eBATROBE].misc4 = 1;
13467 //guysbuf[eSUMMONER].misc4 = 1;
13468 62 guysbuf[eWWIZ].misc4 = 1;
13469 62 guysbuf[eDODONGO].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13470 62 guysbuf[eDODONGOBS].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13471 62 }
13472
2/2
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 12 times.
588 if(Header->zelda_version == 0x190)
13473 {
13474 12 al_trace("Setting Tribble Properties for Version: %x", Header->zelda_version);
13475 12 guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13476 12 guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13477 12 }
13478
13479 // The versions here may not be correct
13480 // zelda_version>=0x211 handled at guyversion<24
13481
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 570 times.
588 if(Header->zelda_version <= 0x190)
13482 {
13483 18 guysbuf[eCENT1].misc3 = 0;
13484 18 guysbuf[eCENT2].misc3 = 0;
13485 18 guysbuf[eMOLDORM].misc2 = 0;
13486 //guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13487 //guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13488 18 }
13489
2/2
✓ Branch 0 taken 526 times.
✓ Branch 1 taken 44 times.
570 else if(Header->zelda_version <= 0x210)
13490 {
13491 44 guysbuf[eCENT1].misc3 = 1;
13492 44 guysbuf[eCENT2].misc3 = 1;
13493 44 guysbuf[eMOLDORM].misc2 = 0;
13494 44 }
13495
13496
2/2
✓ Branch 0 taken 526 times.
✓ Branch 1 taken 62 times.
588 if ( Header->zelda_version < 0x211 ) //Default rest rates for phantom ghinis, peahats and keese in < 2.50 quests
13497 {
13498 62 guysbuf[eKEESE1].misc16 = 120;
13499 62 guysbuf[eKEESE2].misc16 = 120;
13500 62 guysbuf[eKEESE3].misc16 = 120;
13501 62 guysbuf[eKEESETRIB].misc16 = 120;
13502 62 guysbuf[eKEESE1].misc17 = 16;
13503 62 guysbuf[eKEESE2].misc17 = 16;
13504 62 guysbuf[eKEESE3].misc17 = 16;
13505 62 guysbuf[eKEESETRIB].misc17 = 16;
13506
13507 62 guysbuf[ePEAHAT].misc16 = 80;
13508 62 guysbuf[ePEAHAT].misc17 = 16;
13509
13510 62 guysbuf[eGHINI2].misc16 = 120;
13511 62 guysbuf[eGHINI2].misc17 = 10;
13512
13513
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 47 times.
62 if (replay_version_check(20))
13514 {
13515 47 guysbuf[eGHINI2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13516 47 guysbuf[eMOLDORM].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13517 47 guysbuf[eKEESETRIB].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13518 47 guysbuf[eKEESE3].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13519 47 guysbuf[eKEESE2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13520 47 guysbuf[eKEESE1].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13521 47 guysbuf[eTEK1].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13522 47 guysbuf[eTEK2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13523 47 guysbuf[ePEAHAT].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13524 47 guysbuf[eROCK].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13525 47 guysbuf[eTRAP].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13526 47 guysbuf[eWALLM].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13527 47 guysbuf[ePOLSV].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13528 47 guysbuf[eMANHAN].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13529 47 guysbuf[eGLEEOK1].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13530 47 guysbuf[eGLEEOK2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13531 47 guysbuf[eGLEEOK3].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13532 47 guysbuf[eGLEEOK4].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13533 47 guysbuf[eDIG1].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13534 47 guysbuf[eDIG3].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13535 47 guysbuf[eDIGPUP1].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13536 47 guysbuf[eDIGPUP2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13537 47 guysbuf[eDIGPUP3].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13538 47 guysbuf[eDIGPUP4].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13539 47 guysbuf[eRAQUAM].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13540 47 guysbuf[eITEMFAIRY].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13541 47 guysbuf[eFIRE].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13542 47 guysbuf[eMANHAN2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13543 47 guysbuf[eTRAP_H].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13544 47 guysbuf[eTRAP_V].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13545 47 guysbuf[eTRAP_LR].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13546 47 guysbuf[eTRAP_UD].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13547 47 guysbuf[ePATRA1].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13548 47 guysbuf[ePATRA2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13549 47 guysbuf[ePATRABS].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13550 47 guysbuf[eBAT].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13551 47 guysbuf[eGLEEOK1F].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13552 47 guysbuf[eGLEEOK2F].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13553 47 guysbuf[eGLEEOK3F].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13554 47 guysbuf[eGLEEOK4F].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13555 47 guysbuf[eTRIGGER].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13556 47 guysbuf[ePATRAL2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13557 47 guysbuf[ePATRAL3].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13558 47 guysbuf[eGOHMA1].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13559 47 guysbuf[eGOHMA2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13560 47 guysbuf[eGOHMA3].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13561 47 guysbuf[eGOHMA4].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13562 47 guysbuf[eMPOLSV].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13563 47 guysbuf[eWPOLSV].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13564 47 }
13565 62 }
13566
13567
13568
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 526 times.
588 if(guyversion<=2)
13569 {
13570 62 return readherosprites2(f, guyversion==2?0:-1, 0);
13571 }
13572
13573
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 526 times.
526 if(guyversion > 3)
13574 {
13575 guydata tempguy;
13576
13577
2/2
✓ Branch 0 taken 269312 times.
✓ Branch 1 taken 526 times.
269838 for(int32_t i=0; i<MAXGUYS; i++)
13578 {
13579
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(guyversion < 23) // May 2012 : 512 max enemies
13580 {
13581 if(i >= OLDBETAMAXGUYS)
13582 {
13583 memset(&guysbuf[i], 0, sizeof(guydata));
13584 continue;
13585 }
13586 }
13587
13588 269312 memset(&tempguy, 0, sizeof(guydata));
13589
13590
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(!p_igetl(&(tempguy.flags),f))
13591 {
13592 return qe_invalid;
13593 }
13594
13595
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(!p_igetl(&(tempguy.flags2),f))
13596 {
13597 return qe_invalid;
13598 }
13599
13600
2/2
✓ Branch 0 taken 201728 times.
✓ Branch 1 taken 67584 times.
269312 if ( guyversion >= 36 ) //expanded tiles
13601 {
13602
1/2
✓ Branch 0 taken 201728 times.
✗ Branch 1 not taken.
201728 if(!p_igetl(&(tempguy.tile),f))
13603 {
13604 return qe_invalid;
13605 }
13606 201728 }
13607 else
13608 {
13609
1/2
✓ Branch 0 taken 67584 times.
✗ Branch 1 not taken.
67584 if(!p_igetw(&(tempguy.tile),f))
13610 {
13611 return qe_invalid;
13612 }
13613 }
13614
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(!p_getc(&(tempguy.width),f))
13615 {
13616 return qe_invalid;
13617 }
13618
13619
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(!p_getc(&(tempguy.height),f))
13620 {
13621 return qe_invalid;
13622 }
13623
13624
2/2
✓ Branch 0 taken 201728 times.
✓ Branch 1 taken 67584 times.
269312 if ( guyversion >= 36 ) //expanded tiles
13625 {
13626
1/2
✓ Branch 0 taken 201728 times.
✗ Branch 1 not taken.
201728 if(!p_igetl(&(tempguy.s_tile),f))
13627 {
13628 return qe_invalid;
13629 }
13630 201728 }
13631 else
13632 {
13633
1/2
✓ Branch 0 taken 67584 times.
✗ Branch 1 not taken.
67584 if(!p_igetw(&(tempguy.s_tile),f))
13634 {
13635 return qe_invalid;
13636 }
13637 }
13638
13639
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(!p_getc(&(tempguy.s_width),f))
13640 {
13641 return qe_invalid;
13642 }
13643
13644
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(!p_getc(&(tempguy.s_height),f))
13645 {
13646 return qe_invalid;
13647 }
13648
13649
2/2
✓ Branch 0 taken 201728 times.
✓ Branch 1 taken 67584 times.
269312 if ( guyversion >= 36 ) //expanded tiles
13650 {
13651
1/2
✓ Branch 0 taken 201728 times.
✗ Branch 1 not taken.
201728 if(!p_igetl(&(tempguy.e_tile),f))
13652 {
13653 return qe_invalid;
13654 }
13655 201728 }
13656 else
13657 {
13658
1/2
✓ Branch 0 taken 67584 times.
✗ Branch 1 not taken.
67584 if(!p_igetw(&(tempguy.e_tile),f))
13659 {
13660 return qe_invalid;
13661 }
13662 }
13663
13664
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(!p_getc(&(tempguy.e_width),f))
13665 {
13666 return qe_invalid;
13667 }
13668
13669
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(!p_getc(&(tempguy.e_height),f))
13670 {
13671 return qe_invalid;
13672 }
13673
13674
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(!p_igetw(&(tempguy.hp),f))
13675 {
13676 return qe_invalid;
13677 }
13678
13679
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(!p_igetw(&(tempguy.family),f))
13680 {
13681 return qe_invalid;
13682 }
13683
13684
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 269312 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
269312 if(guyversion < 9 && (i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)) // Whoops, forgot about Darknuts...
13685 {
13686 if(get_qr(qr_NEWENEMYTILES))
13687 {
13688 tempguy.s_tile=tempguy.e_tile+120;
13689 tempguy.s_width=tempguy.e_width;
13690 tempguy.s_height=tempguy.e_height;
13691 }
13692 else tempguy.s_tile=860;
13693 }
13694
13695
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(!p_igetw(&(tempguy.cset),f))
13696 {
13697 return qe_invalid;
13698 }
13699
13700
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(!p_igetw(&(tempguy.anim),f))
13701 {
13702 return qe_invalid;
13703 }
13704
13705
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(!p_igetw(&(tempguy.e_anim),f))
13706 {
13707 return qe_invalid;
13708 }
13709
13710
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(!p_igetw(&(tempguy.frate),f))
13711 {
13712 return qe_invalid;
13713 }
13714
13715
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(!p_igetw(&(tempguy.e_frate),f))
13716 {
13717 return qe_invalid;
13718 }
13719
13720
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(guyversion < 13) // April 2009
13721 {
13722 if(get_bit(deprecated_rules, qr_SLOWENEMYANIM_DEP))
13723 {
13724 tempguy.frate *= 2;
13725 tempguy.e_frate *= 2;
13726 }
13727 }
13728
13729
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(guyversion < 14) // May 1 2009
13730 {
13731 if(tempguy.anim==a2FRMSLOW)
13732 {
13733 tempguy.anim=a2FRM;
13734 tempguy.frate *= 2;
13735 }
13736
13737 if(tempguy.e_anim==a2FRMSLOW)
13738 {
13739 tempguy.e_anim=a2FRM;
13740 tempguy.e_frate *= 2;
13741 }
13742
13743 if(tempguy.anim==aFLIPSLOW)
13744 {
13745 tempguy.anim=aFLIP;
13746 tempguy.frate *= 2;
13747 }
13748
13749 if(tempguy.e_anim==aFLIPSLOW)
13750 {
13751 tempguy.e_anim=aFLIP;
13752 tempguy.e_frate *= 2;
13753 }
13754
13755 if(tempguy.anim == aNEWDWALK) tempguy.anim = a4FRM4DIR;
13756
13757 if(tempguy.e_anim == aNEWDWALK) tempguy.e_anim = a4FRM4DIR;
13758
13759 if(tempguy.anim == aNEWPOLV || tempguy.anim == a4FRM3TRAP)
13760 {
13761 tempguy.anim=a4FRM4DIR;
13762 tempguy.s_tile=(get_qr(qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
13763 }
13764
13765 if(tempguy.e_anim == aNEWPOLV || tempguy.e_anim == a4FRM3TRAP)
13766 {
13767 tempguy.e_anim=a4FRM4DIR;
13768 tempguy.s_tile=(get_qr(qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
13769 }
13770 }
13771
13772
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(!p_igetw(&(tempguy.dp),f))
13773 {
13774 return qe_invalid;
13775 }
13776
13777 //correction for guy fire
13778
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(guyversion < 6)
13779 {
13780 if(i == gFIRE)
13781 tempguy.dp = 2;
13782 }
13783
13784
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(!p_igetw(&(tempguy.wdp),f))
13785 {
13786 return qe_invalid;
13787 }
13788
13789
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(!p_igetw(&(tempguy.weapon),f))
13790 {
13791 return qe_invalid;
13792 }
13793
13794 //correction for bosses using triple, "rising" fireballs
13795
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(guyversion < 5)
13796 {
13797 if(i == eLAQUAM || i == eRAQUAM || i == eGOHMA1 || i == eGOHMA2 ||
13798 i == eGOHMA3 || i == eGOHMA4)
13799 {
13800 if(tempguy.weapon == ewFireball)
13801 tempguy.weapon = ewFireball2;
13802 }
13803 }
13804
13805
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(!p_igetw(&(tempguy.rate),f))
13806 {
13807 return qe_invalid;
13808 }
13809
13810
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(!p_igetw(&(tempguy.hrate),f))
13811 {
13812 return qe_invalid;
13813 }
13814
13815
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(!p_igetw(&(tempguy.step),f))
13816 {
13817 return qe_invalid;
13818 }
13819
13820 // HIGHLY UNORTHODOX UPDATING THING, part 2
13821
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 269312 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
269312 if(fixpolsvoice && tempguy.family==eePOLSV)
13822 {
13823 tempguy.step /= 2;
13824 }
13825
13826
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(!p_igetw(&(tempguy.homing),f))
13827 {
13828 return qe_invalid;
13829 }
13830
13831
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(!p_igetw(&(tempguy.grumble),f))
13832 {
13833 return qe_invalid;
13834 }
13835
13836
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(!p_igetw(&(tempguy.item_set),f))
13837 {
13838 return qe_invalid;
13839 }
13840
13841
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(guyversion>=22) // Version 22: Expand misc attributes to 32 bits
13842 {
13843
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(!p_igetl(&(tempguy.misc1),f))
13844 {
13845 return qe_invalid;
13846 }
13847
13848
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(!p_igetl(&(tempguy.misc2),f))
13849 {
13850 return qe_invalid;
13851 }
13852
13853
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(!p_igetl(&(tempguy.misc3),f))
13854 {
13855 return qe_invalid;
13856 }
13857
13858
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(!p_igetl(&(tempguy.misc4),f))
13859 {
13860 return qe_invalid;
13861 }
13862
13863
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(!p_igetl(&(tempguy.misc5),f))
13864 {
13865 return qe_invalid;
13866 }
13867
13868
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(!p_igetl(&(tempguy.misc6),f))
13869 {
13870 return qe_invalid;
13871 }
13872
13873
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(!p_igetl(&(tempguy.misc7),f))
13874 {
13875 return qe_invalid;
13876 }
13877
13878
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(!p_igetl(&(tempguy.misc8),f))
13879 {
13880 return qe_invalid;
13881 }
13882
13883
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(!p_igetl(&(tempguy.misc9),f))
13884 {
13885 return qe_invalid;
13886 }
13887
13888
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(!p_igetl(&(tempguy.misc10),f))
13889 {
13890 return qe_invalid;
13891 }
13892 269312 }
13893 else
13894 {
13895 int16_t tempMisc;
13896
13897 if(!p_igetw(&tempMisc,f))
13898 {
13899 return qe_invalid;
13900 }
13901
13902 tempguy.misc1=tempMisc;
13903
13904 if(!p_igetw(&tempMisc,f))
13905 {
13906 return qe_invalid;
13907 }
13908
13909 tempguy.misc2=tempMisc;
13910
13911 if(!p_igetw(&tempMisc,f))
13912 {
13913 return qe_invalid;
13914 }
13915
13916 tempguy.misc3=tempMisc;
13917
13918 if(!p_igetw(&tempMisc,f))
13919 {
13920 return qe_invalid;
13921 }
13922
13923 tempguy.misc4=tempMisc;
13924
13925 if(!p_igetw(&tempMisc,f))
13926 {
13927 return qe_invalid;
13928 }
13929
13930 tempguy.misc5=tempMisc;
13931
13932 if(guyversion < 13) // April 2009 - a tiny Wizzrobe update
13933 {
13934 if(tempguy.family == eeWIZZ && !(tempguy.misc1))
13935 tempguy.misc5 = 74;
13936 }
13937
13938 if(!p_igetw(&tempMisc,f))
13939 {
13940 return qe_invalid;
13941 }
13942
13943 tempguy.misc6=tempMisc;
13944
13945 if(!p_igetw(&tempMisc,f))
13946 {
13947 return qe_invalid;
13948 }
13949
13950 tempguy.misc7=tempMisc;
13951
13952 if(!p_igetw(&tempMisc,f))
13953 {
13954 return qe_invalid;
13955 }
13956
13957 tempguy.misc8=tempMisc;
13958
13959 if(!p_igetw(&tempMisc,f))
13960 {
13961 return qe_invalid;
13962 }
13963
13964 tempguy.misc9=tempMisc;
13965
13966 if(!p_igetw(&tempMisc,f))
13967 {
13968 return qe_invalid;
13969 }
13970
13971 tempguy.misc10=tempMisc;
13972 }
13973
13974
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(!p_igetw(&(tempguy.bgsfx),f))
13975 {
13976 return qe_invalid;
13977 }
13978
13979
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(!p_igetw(&(tempguy.bosspal),f))
13980 {
13981 return qe_invalid;
13982 }
13983
13984
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(!p_igetw(&(tempguy.extend),f))
13985 {
13986 return qe_invalid;
13987 }
13988
13989 //! Enemy Defences
13990
13991 //If a 2.50 quest, use only the 2.5 defences.
13992
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 269312 times.
269312 if(guyversion >= 16 ) // November 2009 - Super Enemy Editor
13993 {
13994
2/2
✓ Branch 0 taken 5116928 times.
✓ Branch 1 taken 269312 times.
5386240 for(int32_t j=0; j<edefLAST; j++)
13995 {
13996
1/2
✓ Branch 0 taken 5116928 times.
✗ Branch 1 not taken.
5116928 if(!p_getc(&(tempguy.defense[j]),f))
13997 {
13998 return qe_invalid;
13999 }
14000 5116928 }
14001 //then copy the generic script defence to all the new script defences
14002
14003 269312 }
14004
14005
14006
14007
14008
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 269312 times.
269312 if(guyversion >= 18)
14009 {
14010
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(!p_getc(&(tempguy.hitsfx),f))
14011 {
14012 return qe_invalid;
14013 }
14014
14015
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(!p_getc(&(tempguy.deadsfx),f))
14016 {
14017 return qe_invalid;
14018 }
14019 269312 }
14020
14021
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(guyversion >= 22)
14022 {
14023
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(!p_igetl(&(tempguy.misc11),f))
14024 {
14025 return qe_invalid;
14026 }
14027
14028
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(!p_igetl(&(tempguy.misc12),f))
14029 {
14030 return qe_invalid;
14031 }
14032 269312 }
14033 else if(guyversion >= 19)
14034 {
14035 int16_t tempMisc;
14036
14037 if(!p_igetw(&tempMisc,f))
14038 {
14039 return qe_invalid;
14040 }
14041
14042 tempguy.misc11=tempMisc;
14043
14044 if(!p_igetw(&tempMisc,f))
14045 {
14046 return qe_invalid;
14047 }
14048
14049 tempguy.misc12=tempMisc;
14050 }
14051
14052 //If a 2.54 or later quest, use all of the defences.
14053
2/2
✓ Branch 0 taken 67584 times.
✓ Branch 1 taken 201728 times.
269312 if(guyversion > 24) // Add new guyversion conditional statement
14054 {
14055
2/2
✓ Branch 0 taken 4438016 times.
✓ Branch 1 taken 201728 times.
4639744 for(int32_t j=edefLAST; j<edefLAST255; j++)
14056 {
14057
1/2
✓ Branch 0 taken 4438016 times.
✗ Branch 1 not taken.
4438016 if(!p_getc(&(tempguy.defense[j]),f))
14058 {
14059 return qe_invalid;
14060 }
14061 4438016 }
14062 201728 }
14063
14064
2/2
✓ Branch 0 taken 201728 times.
✓ Branch 1 taken 67584 times.
269312 if(guyversion <= 24) // Port over generic script settings from old quests in the new editor.
14065 {
14066
2/2
✓ Branch 0 taken 675840 times.
✓ Branch 1 taken 67584 times.
743424 for(int32_t j=edefSCRIPT01; j<=edefSCRIPT10; j++)
14067 {
14068 675840 tempguy.defense[j] = tempguy.defense[edefSCRIPT] ;
14069 675840 }
14070 67584 }
14071
14072 //tilewidth, tileheight, hitwidth, hitheight, hitzheight, hitxofs, hityofs, hitzofs
14073
2/2
✓ Branch 0 taken 67584 times.
✓ Branch 1 taken 201728 times.
269312 if(guyversion > 25)
14074 {
14075
1/2
✓ Branch 0 taken 201728 times.
✗ Branch 1 not taken.
201728 if(!p_igetl(&(tempguy.txsz),f))
14076 {
14077 return qe_invalid;
14078 }
14079
1/2
✓ Branch 0 taken 201728 times.
✗ Branch 1 not taken.
201728 if(!p_igetl(&(tempguy.tysz),f))
14080 {
14081 return qe_invalid;
14082 }
14083
1/2
✓ Branch 0 taken 201728 times.
✗ Branch 1 not taken.
201728 if(!p_igetl(&(tempguy.hxsz),f))
14084 {
14085 return qe_invalid;
14086 }
14087
1/2
✓ Branch 0 taken 201728 times.
✗ Branch 1 not taken.
201728 if(!p_igetl(&(tempguy.hysz),f))
14088 {
14089 return qe_invalid;
14090 }
14091
1/2
✓ Branch 0 taken 201728 times.
✗ Branch 1 not taken.
201728 if(!p_igetl(&(tempguy.hzsz),f))
14092 {
14093 return qe_invalid;
14094 }
14095 /* Is it safe to read a fixed with getl, or do I need to typecast it? -Z
14096
14097 */
14098 201728 }
14099 //More Enemy Editor vars for 2.60
14100
2/2
✓ Branch 0 taken 67584 times.
✓ Branch 1 taken 201728 times.
269312 if(guyversion > 26)
14101 {
14102
1/2
✓ Branch 0 taken 201728 times.
✗ Branch 1 not taken.
201728 if(!p_igetl(&(tempguy.hxofs),f))
14103 {
14104 return qe_invalid;
14105 }
14106
1/2
✓ Branch 0 taken 201728 times.
✗ Branch 1 not taken.
201728 if(!p_igetl(&(tempguy.hyofs),f))
14107 {
14108 return qe_invalid;
14109 }
14110
1/2
✓ Branch 0 taken 201728 times.
✗ Branch 1 not taken.
201728 if(!p_igetl(&(tempguy.xofs),f))
14111 {
14112 return qe_invalid;
14113 }
14114
1/2
✓ Branch 0 taken 201728 times.
✗ Branch 1 not taken.
201728 if(!p_igetl(&(tempguy.yofs),f))
14115 {
14116 return qe_invalid;
14117 }
14118
1/2
✓ Branch 0 taken 201728 times.
✗ Branch 1 not taken.
201728 if(!p_igetl(&(tempguy.zofs),f))
14119 {
14120 return qe_invalid;
14121 }
14122 201728 }
14123
14124
2/2
✓ Branch 0 taken 201728 times.
✓ Branch 1 taken 67584 times.
269312 if(guyversion <= 27) // Port over generic script settings from old quests in the new editor.
14125 {
14126 67584 tempguy.wpnsprite = 0;
14127 67584 }
14128
14129
2/2
✓ Branch 0 taken 67584 times.
✓ Branch 1 taken 201728 times.
269312 if(guyversion > 27)
14130 {
14131
1/2
✓ Branch 0 taken 201728 times.
✗ Branch 1 not taken.
201728 if(!p_igetl(&(tempguy.wpnsprite),f))
14132 {
14133 return qe_invalid;
14134 }
14135 201728 }
14136
2/2
✓ Branch 0 taken 201728 times.
✓ Branch 1 taken 67584 times.
269312 if(guyversion <= 28) // Port over generic script settings from old quests in the new editor.
14137 {
14138 67584 tempguy.SIZEflags = 0;
14139 67584 }
14140
2/2
✓ Branch 0 taken 67584 times.
✓ Branch 1 taken 201728 times.
269312 if(guyversion > 28)
14141 {
14142
1/2
✓ Branch 0 taken 201728 times.
✗ Branch 1 not taken.
201728 if(!p_igetl(&(tempguy.SIZEflags),f))
14143 {
14144 return qe_invalid;
14145 }
14146
14147 201728 }
14148
2/2
✓ Branch 0 taken 201728 times.
✓ Branch 1 taken 67584 times.
269312 if(guyversion < 30) // Port over generic script settings from old quests in the new editor.
14149 {
14150 67584 tempguy.frozentile = 0;
14151 67584 tempguy.frozencset = 0;
14152 67584 tempguy.frozenclock = 0;
14153
2/2
✓ Branch 0 taken 675840 times.
✓ Branch 1 taken 67584 times.
743424 for ( int32_t q = 0; q < 10; q++ ) tempguy.frozenmisc[q] = 0;
14154 67584 }
14155
2/2
✓ Branch 0 taken 67584 times.
✓ Branch 1 taken 201728 times.
269312 if(guyversion >= 30)
14156 {
14157
1/2
✓ Branch 0 taken 201728 times.
✗ Branch 1 not taken.
201728 if(!p_igetl(&(tempguy.frozentile),f))
14158 {
14159 return qe_invalid;
14160 }
14161
1/2
✓ Branch 0 taken 201728 times.
✗ Branch 1 not taken.
201728 if(!p_igetl(&(tempguy.frozencset),f))
14162 {
14163 return qe_invalid;
14164 }
14165
1/2
✓ Branch 0 taken 201728 times.
✗ Branch 1 not taken.
201728 if(!p_igetl(&(tempguy.frozenclock),f))
14166 {
14167 return qe_invalid;
14168 }
14169
2/2
✓ Branch 0 taken 2017280 times.
✓ Branch 1 taken 201728 times.
2219008 for ( int32_t q = 0; q < 10; q++ ) {
14170
1/2
✓ Branch 0 taken 2017280 times.
✗ Branch 1 not taken.
2017280 if(!p_igetw(&(tempguy.frozenmisc[q]),f))
14171 {
14172 return qe_invalid;
14173 }
14174 2017280 }
14175
14176 201728 }
14177
14178
2/2
✓ Branch 0 taken 67584 times.
✓ Branch 1 taken 201728 times.
269312 if(guyversion >= 34)
14179 {
14180
1/2
✓ Branch 0 taken 201728 times.
✗ Branch 1 not taken.
201728 if(!p_igetw(&(tempguy.firesfx),f))
14181 {
14182 return qe_invalid;
14183 }
14184
1/2
✓ Branch 0 taken 201728 times.
✗ Branch 1 not taken.
201728 if(!p_igetl(&(tempguy.misc16),f))
14185 {
14186 return qe_invalid;
14187 }
14188
1/2
✓ Branch 0 taken 201728 times.
✗ Branch 1 not taken.
201728 if(!p_igetl(&(tempguy.misc17),f))
14189 {
14190 return qe_invalid;
14191 }
14192
1/2
✓ Branch 0 taken 201728 times.
✗ Branch 1 not taken.
201728 if(!p_igetl(&(tempguy.misc18),f))
14193 {
14194 return qe_invalid;
14195 }
14196
1/2
✓ Branch 0 taken 201728 times.
✗ Branch 1 not taken.
201728 if(!p_igetl(&(tempguy.misc19),f))
14197 {
14198 return qe_invalid;
14199 }
14200
1/2
✓ Branch 0 taken 201728 times.
✗ Branch 1 not taken.
201728 if(!p_igetl(&(tempguy.misc20),f))
14201 {
14202 return qe_invalid;
14203 }
14204
1/2
✓ Branch 0 taken 201728 times.
✗ Branch 1 not taken.
201728 if(!p_igetl(&(tempguy.misc21),f))
14205 {
14206 return qe_invalid;
14207 }
14208
1/2
✓ Branch 0 taken 201728 times.
✗ Branch 1 not taken.
201728 if(!p_igetl(&(tempguy.misc22),f))
14209 {
14210 return qe_invalid;
14211 }
14212
1/2
✓ Branch 0 taken 201728 times.
✗ Branch 1 not taken.
201728 if(!p_igetl(&(tempguy.misc23),f))
14213 {
14214 return qe_invalid;
14215 }
14216
1/2
✓ Branch 0 taken 201728 times.
✗ Branch 1 not taken.
201728 if(!p_igetl(&(tempguy.misc24),f))
14217 {
14218 return qe_invalid;
14219 }
14220
1/2
✓ Branch 0 taken 201728 times.
✗ Branch 1 not taken.
201728 if(!p_igetl(&(tempguy.misc25),f))
14221 {
14222 return qe_invalid;
14223 }
14224
1/2
✓ Branch 0 taken 201728 times.
✗ Branch 1 not taken.
201728 if(!p_igetl(&(tempguy.misc26),f))
14225 {
14226 return qe_invalid;
14227 }
14228
1/2
✓ Branch 0 taken 201728 times.
✗ Branch 1 not taken.
201728 if(!p_igetl(&(tempguy.misc27),f))
14229 {
14230 return qe_invalid;
14231 }
14232
1/2
✓ Branch 0 taken 201728 times.
✗ Branch 1 not taken.
201728 if(!p_igetl(&(tempguy.misc28),f))
14233 {
14234 return qe_invalid;
14235 }
14236
1/2
✓ Branch 0 taken 201728 times.
✗ Branch 1 not taken.
201728 if(!p_igetl(&(tempguy.misc29),f))
14237 {
14238 return qe_invalid;
14239 }
14240
1/2
✓ Branch 0 taken 201728 times.
✗ Branch 1 not taken.
201728 if(!p_igetl(&(tempguy.misc30),f))
14241 {
14242 return qe_invalid;
14243 }
14244
1/2
✓ Branch 0 taken 201728 times.
✗ Branch 1 not taken.
201728 if(!p_igetl(&(tempguy.misc31),f))
14245 {
14246 return qe_invalid;
14247 }
14248
1/2
✓ Branch 0 taken 201728 times.
✗ Branch 1 not taken.
201728 if(!p_igetl(&(tempguy.misc32),f))
14249 {
14250 return qe_invalid;
14251 }
14252
14253
2/2
✓ Branch 0 taken 6455296 times.
✓ Branch 1 taken 201728 times.
6657024 for ( int32_t q = 0; q < 32; q++ ) {
14254
1/2
✓ Branch 0 taken 6455296 times.
✗ Branch 1 not taken.
6455296 if(!p_igetl(&(tempguy.movement[q]),f))
14255 {
14256 return qe_invalid;
14257 }
14258 6455296 }
14259
2/2
✓ Branch 0 taken 6455296 times.
✓ Branch 1 taken 201728 times.
6657024 for ( int32_t q = 0; q < 32; q++ ) {
14260
1/2
✓ Branch 0 taken 6455296 times.
✗ Branch 1 not taken.
6455296 if(!p_igetl(&(tempguy.new_weapon[q]),f))
14261 {
14262 return qe_invalid;
14263 }
14264 6455296 }
14265
1/2
✓ Branch 0 taken 201728 times.
✗ Branch 1 not taken.
201728 if(!p_igetw(&(tempguy.script),f))
14266 {
14267 return qe_invalid;
14268 }
14269 //al_trace("NPC Script ID is: %d\n",tempguy.script);
14270
2/2
✓ Branch 0 taken 1613824 times.
✓ Branch 1 taken 201728 times.
1815552 for ( int32_t q = 0; q < 8; q++ )
14271 {
14272
1/2
✓ Branch 0 taken 1613824 times.
✗ Branch 1 not taken.
1613824 if(!p_igetl(&(tempguy.initD[q]),f))
14273 {
14274 return qe_invalid;
14275 }
14276 1613824 }
14277
2/2
✓ Branch 0 taken 403456 times.
✓ Branch 1 taken 201728 times.
605184 for ( int32_t q = 0; q < 2; q++ )
14278 {
14279
1/2
✓ Branch 0 taken 403456 times.
✗ Branch 1 not taken.
403456 if(!p_igetl(&(tempguy.initA[q]),f))
14280 {
14281 return qe_invalid;
14282 }
14283 403456 }
14284
14285 201728 }
14286
14287
2/2
✓ Branch 0 taken 67584 times.
✓ Branch 1 taken 201728 times.
269312 if(guyversion >= 37)
14288 {
14289
1/2
✓ Branch 0 taken 201728 times.
✗ Branch 1 not taken.
201728 if(!p_igetl(&(tempguy.editorflags),f))
14290 {
14291 return qe_invalid;
14292 }
14293 201728 }
14294
2/2
✓ Branch 0 taken 201728 times.
✓ Branch 1 taken 67584 times.
269312 if ( guyversion < 37 ) { tempguy.editorflags = 0; }
14295
2/2
✓ Branch 0 taken 67584 times.
✓ Branch 1 taken 201728 times.
269312 if(guyversion >= 38)
14296 {
14297
1/2
✓ Branch 0 taken 201728 times.
✗ Branch 1 not taken.
201728 if(!p_igetl(&(tempguy.misc13),f))
14298 {
14299 return qe_invalid;
14300 }
14301
1/2
✓ Branch 0 taken 201728 times.
✗ Branch 1 not taken.
201728 if(!p_igetl(&(tempguy.misc14),f))
14302 {
14303 return qe_invalid;
14304 }
14305
1/2
✓ Branch 0 taken 201728 times.
✗ Branch 1 not taken.
201728 if(!p_igetl(&(tempguy.misc15),f))
14306 {
14307 return qe_invalid;
14308 }
14309
14310 201728 }
14311
2/2
✓ Branch 0 taken 201728 times.
✓ Branch 1 taken 67584 times.
269312 if ( guyversion < 38 )
14312 {
14313 67584 tempguy.misc13 = 0;
14314 67584 tempguy.misc14 = 0;
14315 67584 tempguy.misc15 = 0;
14316 67584 }
14317
14318
2/2
✓ Branch 0 taken 67584 times.
✓ Branch 1 taken 201728 times.
269312 if ( guyversion >= 39 )
14319 {
14320
2/2
✓ Branch 0 taken 1613824 times.
✓ Branch 1 taken 201728 times.
1815552 for ( int32_t q = 0; q < 8; q++ )
14321 {
14322
2/2
✓ Branch 0 taken 104898560 times.
✓ Branch 1 taken 1613824 times.
106512384 for ( int32_t w = 0; w < 65; w++ )
14323 {
14324
1/2
✓ Branch 0 taken 104898560 times.
✗ Branch 1 not taken.
104898560 if(!p_getc(&(tempguy.initD_label[q][w]),f))
14325 {
14326 return qe_invalid;
14327 }
14328 104898560 }
14329
2/2
✓ Branch 0 taken 104898560 times.
✓ Branch 1 taken 1613824 times.
106512384 for ( int32_t w = 0; w < 65; w++ )
14330 {
14331
1/2
✓ Branch 0 taken 104898560 times.
✗ Branch 1 not taken.
104898560 if(!p_getc(&(tempguy.weapon_initD_label[q][w]),f))
14332 {
14333 return qe_invalid;
14334 }
14335 104898560 }
14336 1613824 }
14337
14338
14339 201728 }
14340
2/2
✓ Branch 0 taken 201728 times.
✓ Branch 1 taken 67584 times.
269312 if ( guyversion < 39 ) //apply old InitD strings to both
14341 {
14342
2/2
✓ Branch 0 taken 540672 times.
✓ Branch 1 taken 67584 times.
608256 for ( int32_t q = 0; q < 8; q++ )
14343 {
14344 540672 sprintf(tempguy.initD_label[q],"InitD[%d]",q);
14345 540672 sprintf(tempguy.weapon_initD_label[q],"InitD[%d]",q);
14346 540672 }
14347 67584 }
14348
2/2
✓ Branch 0 taken 67584 times.
✓ Branch 1 taken 201728 times.
269312 if ( guyversion >= 40 )
14349 {
14350
1/2
✓ Branch 0 taken 201728 times.
✗ Branch 1 not taken.
201728 if(!p_igetw(&(tempguy.weaponscript),f))
14351 {
14352 return qe_invalid;
14353 }
14354 201728 }
14355
2/2
✓ Branch 0 taken 201728 times.
✓ Branch 1 taken 67584 times.
269312 if ( guyversion < 40 )
14356 {
14357 67584 tempguy.weaponscript = 0;
14358 67584 }
14359 //eweapon script InitD
14360
2/2
✓ Branch 0 taken 67584 times.
✓ Branch 1 taken 201728 times.
269312 if ( guyversion >= 41 )
14361 {
14362
2/2
✓ Branch 0 taken 1613824 times.
✓ Branch 1 taken 201728 times.
1815552 for ( int32_t q = 0; q < 8; q++ )
14363 {
14364
1/2
✓ Branch 0 taken 1613824 times.
✗ Branch 1 not taken.
1613824 if(!p_igetl(&(tempguy.weap_initiald[q]),f))
14365 {
14366 return qe_invalid;
14367 }
14368 1613824 }
14369
1/2
✓ Branch 0 taken 201728 times.
✗ Branch 1 not taken.
201728 if ( guy_cversion < 4 )
14370 {
14371 if ( tempguy.family == eeKEESE )
14372 {
14373
14374 if ( !tempguy.misc1 )
14375 {
14376 tempguy.misc16 = 120;
14377 tempguy.misc17 = 16;
14378
14379 }
14380 }
14381 if ( tempguy.family == eePEAHAT )
14382 {
14383 tempguy.misc16 = 80;
14384 tempguy.misc17 = 16;
14385 }
14386
14387 if ( tempguy.family == eeGHINI )
14388 {
14389 tempguy.misc16 = 120;
14390 tempguy.misc17 = 10;
14391 }
14392
14393 }
14394 201728 }
14395
14396
14397
14398 //default weapon sprites (quest version < 2.54)
14399 //port over old defaults -Z
14400
2/2
✓ Branch 0 taken 201728 times.
✓ Branch 1 taken 67584 times.
269312 if(guyversion < 32)
14401 {
14402
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67584 times.
67584 if ( tempguy.wpnsprite <= 0 )
14403 {
14404
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 2001 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 56967 times.
✓ Branch 4 taken 527 times.
✓ Branch 5 taken 488 times.
✓ Branch 6 taken 1377 times.
✓ Branch 7 taken 846 times.
✓ Branch 8 taken 1588 times.
✓ Branch 9 taken 138 times.
✓ Branch 10 taken 41 times.
✓ Branch 11 taken 281 times.
✓ Branch 12 taken 45 times.
✓ Branch 13 taken 605 times.
✓ Branch 14 taken 1232 times.
✓ Branch 15 taken 162 times.
✓ Branch 16 taken 182 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 1104 times.
67584 switch(tempguy.weapon)
14405 {
14406 case wNone:
14407 56967 tempguy.wpnsprite = 0; break;
14408
14409 case wSword:
14410 case wBeam:
14411 case wBrang:
14412 case wBomb:
14413 case wSBomb:
14414 case wLitBomb:
14415 case wLitSBomb:
14416 case wArrow:
14417 case wFire:
14418 case wWhistle:
14419 case wBait:
14420 case wWand:
14421 case wMagic:
14422 case wCatching:
14423 case wWind:
14424 case wRefMagic:
14425 case wRefFireball:
14426 case wRefRock:
14427 case wHammer:
14428 case wHookshot:
14429 case wHSHandle:
14430 case wHSChain:
14431 case wSSparkle:
14432 case wFSparkle:
14433 case wSmack:
14434 case wPhantom:
14435 case wCByrna:
14436 case wRefBeam:
14437 case wStomp:
14438 case lwMax:
14439 case wScript1:
14440 case wScript2:
14441 case wScript3:
14442 case wScript4:
14443 case wScript5:
14444 case wScript6:
14445 case wScript7:
14446 case wScript8:
14447 case wScript9:
14448 case wScript10:
14449 case wIce:
14450 //Cannot use any of these weapons yet.
14451 tempguy.wpnsprite = -1;
14452 break;
14453
14454 case wEnemyWeapons:
14455 2001 case ewFireball: tempguy.wpnsprite = 17; break;
14456
14457 527 case ewArrow: tempguy.wpnsprite = 19; break;
14458 488 case ewBrang: tempguy.wpnsprite = 4; break;
14459 1377 case ewSword: tempguy.wpnsprite = 20; break;
14460 846 case ewRock: tempguy.wpnsprite = 18; break;
14461 1588 case ewMagic: tempguy.wpnsprite = 21; break;
14462 138 case ewBomb: tempguy.wpnsprite = 78; break;
14463 41 case ewSBomb: tempguy.wpnsprite = 79; break;
14464 281 case ewLitBomb: tempguy.wpnsprite = 76; break;
14465 45 case ewLitSBomb: tempguy.wpnsprite = 77; break;
14466 605 case ewFireTrail: tempguy.wpnsprite = 80; break;
14467 1232 case ewFlame: tempguy.wpnsprite = 35; break;
14468 162 case ewWind: tempguy.wpnsprite = 36; break;
14469 182 case ewFlame2: tempguy.wpnsprite = 81; break;
14470 case ewFlame2Trail: tempguy.wpnsprite = 82; break;
14471 case ewIce: tempguy.wpnsprite = 83; break;
14472 1104 case ewFireball2: tempguy.wpnsprite = 17; break; //fireball (rising)
14473
14474
14475 default: break; //No assign.
14476 }
14477 67584 }
14478 67584 }
14479
14480 //default weapon fire sound (quest version < 2.54)
14481 //port over old defaults and zero new data. -Z
14482
2/2
✓ Branch 0 taken 201728 times.
✓ Branch 1 taken 67584 times.
269312 if(guyversion < 34)
14483 {
14484
2/2
✓ Branch 0 taken 2162688 times.
✓ Branch 1 taken 67584 times.
2230272 for ( int32_t q = 0; q < 32; q++ )
14485 {
14486 2162688 tempguy.movement[q] = 0;
14487 2162688 tempguy.new_weapon[q] = 0;
14488
14489 2162688 }
14490
14491 //NPC Script attributes.
14492 67584 tempguy.script = 0; //No scripted enemies existed. -Z
14493
2/2
✓ Branch 0 taken 540672 times.
✓ Branch 1 taken 67584 times.
608256 for ( int32_t q = 0; q < 8; q++ ) tempguy.initD[q] = 0; //Script Data
14494
2/2
✓ Branch 0 taken 135168 times.
✓ Branch 1 taken 67584 times.
202752 for ( int32_t q = 0; q < 2; q++ ) tempguy.initA[q] = 0; //Script Data
14495
14496 67584 tempguy.misc16 = 0;
14497 67584 tempguy.misc17 = 0;
14498 67584 tempguy.misc18 = 0;
14499 67584 tempguy.misc19 = 0;
14500 67584 tempguy.misc20 = 0;
14501 67584 tempguy.misc21 = 0;
14502 67584 tempguy.misc22 = 0;
14503 67584 tempguy.misc23 = 0;
14504 67584 tempguy.misc24 = 0;
14505 67584 tempguy.misc25 = 0;
14506 67584 tempguy.misc26 = 0;
14507 67584 tempguy.misc27 = 0;
14508 67584 tempguy.misc28 = 0;
14509 67584 tempguy.misc29 = 0;
14510 67584 tempguy.misc30 = 0;
14511 67584 tempguy.misc31 = 0;
14512 67584 tempguy.misc32 = 0;
14513
14514 //old default sounds
14515
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67584 times.
67584 if ( tempguy.firesfx <= 0 )
14516 {
14517
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 2001 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 56967 times.
✓ Branch 4 taken 527 times.
✓ Branch 5 taken 488 times.
✓ Branch 6 taken 1377 times.
✓ Branch 7 taken 846 times.
✓ Branch 8 taken 1588 times.
✓ Branch 9 taken 138 times.
✓ Branch 10 taken 41 times.
✓ Branch 11 taken 281 times.
✓ Branch 12 taken 45 times.
✓ Branch 13 taken 605 times.
✓ Branch 14 taken 1232 times.
✓ Branch 15 taken 162 times.
✓ Branch 16 taken 182 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 1104 times.
67584 switch(tempguy.weapon)
14518 {
14519 case wNone:
14520 56967 tempguy.firesfx = 0; break;
14521
14522 case wSword:
14523 case wBeam:
14524 case wBrang:
14525 case wBomb:
14526 case wSBomb:
14527 case wLitBomb:
14528 case wLitSBomb:
14529 case wArrow:
14530 case wFire:
14531 case wWhistle:
14532 case wBait:
14533 case wWand:
14534 case wMagic:
14535 case wCatching:
14536 case wWind:
14537 case wRefMagic:
14538 case wRefFireball:
14539 case wRefRock:
14540 case wHammer:
14541 case wHookshot:
14542 case wHSHandle:
14543 case wHSChain:
14544 case wSSparkle:
14545 case wFSparkle:
14546 case wSmack:
14547 case wPhantom:
14548 case wCByrna:
14549 case wRefBeam:
14550 case wStomp:
14551 case lwMax:
14552 case wScript1:
14553 case wScript2:
14554 case wScript3:
14555 case wScript4:
14556 case wScript5:
14557 case wScript6:
14558 case wScript7:
14559 case wScript8:
14560 case wScript9:
14561 case wScript10:
14562 case wIce:
14563 //Cannot use any of these weapons yet.
14564 tempguy.firesfx = -1;
14565 break;
14566
14567 case wEnemyWeapons:
14568 2001 case ewFireball: tempguy.firesfx = 40; break;
14569
14570 527 case ewArrow: tempguy.firesfx = 1; break; //Ghost.zh has 0?
14571 488 case ewBrang: tempguy.firesfx = 4; break; //Ghost.zh has 0?
14572 1377 case ewSword: tempguy.firesfx = 20; break; //Ghost.zh has 0?
14573 846 case ewRock: tempguy.firesfx = 51; break;
14574 1588 case ewMagic: tempguy.firesfx = 32; break;
14575 138 case ewBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14576 41 case ewSBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14577 281 case ewLitBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14578 45 case ewLitSBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14579 605 case ewFireTrail: tempguy.firesfx = 13; break;
14580 1232 case ewFlame: tempguy.firesfx = 13; break;
14581 162 case ewWind: tempguy.firesfx = 32; break;
14582 182 case ewFlame2: tempguy.firesfx = 13; break;
14583 case ewFlame2Trail: tempguy.firesfx = 13; break;
14584 case ewIce: tempguy.firesfx = 44; break;
14585 1104 case ewFireball2: tempguy.firesfx = 40; break; //fireball (rising)
14586
14587 //what about special attacks (e.g. summoning == 56)
14588 default: break; //No assign.
14589 }
14590 67584 }
14591 67584 }
14592
14593 //Port hardcoded hit sound to the enemy hitsfx defaults for older quests.
14594
4/6
✓ Branch 0 taken 201728 times.
✓ Branch 1 taken 67584 times.
✓ Branch 2 taken 201728 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 201728 times.
269312 if(Header->zelda_version <= 0x250 || ( Header->zelda_version > 0x250 && guyversion < 35 ))
14595 {
14596
2/2
✓ Branch 0 taken 9417 times.
✓ Branch 1 taken 58167 times.
67584 if ( tempguy.hitsfx == 0 ) tempguy.hitsfx = 11;
14597 67584 }
14598 //Keese and bat halt rates.
14599
3/4
✓ Branch 0 taken 67584 times.
✓ Branch 1 taken 201728 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 67584 times.
269312 if ( guyversion < 42 && guy_cversion < 4 )
14600 {
14601
14602
2/2
✓ Branch 0 taken 66713 times.
✓ Branch 1 taken 871 times.
67584 if ( tempguy.family == eeKEESE )
14603 {
14604
14605
2/2
✓ Branch 0 taken 274 times.
✓ Branch 1 taken 597 times.
871 if ( !tempguy.misc1 )
14606 {
14607 597 tempguy.misc16 = 120;
14608 597 tempguy.misc17 = 16;
14609
14610 597 }
14611 871 }
14612
2/2
✓ Branch 0 taken 67287 times.
✓ Branch 1 taken 297 times.
67584 if ( tempguy.family == eePEAHAT )
14613 {
14614 297 tempguy.misc16 = 80;
14615 297 tempguy.misc17 = 16;
14616 297 }
14617
2/2
✓ Branch 0 taken 67452 times.
✓ Branch 1 taken 132 times.
67584 if ( tempguy.family == eeGHINI )
14618 {
14619 132 tempguy.misc16 = 120;
14620 132 tempguy.misc17 = 10;
14621 132 }
14622
14623
14624 67584 }
14625
14626
14627 //miscellaneous other corrections
14628 //fix the mirror wizzrobe -DD
14629
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(guyversion < 7)
14630 {
14631 if(i == eMWIZ)
14632 {
14633 tempguy.misc2 = 0;
14634 tempguy.misc4 = 1;
14635 }
14636 }
14637
14638
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(guyversion < 8)
14639 {
14640 if(i == eGLEEOK1 || i == eGLEEOK2 || i == eGLEEOK3 || i == eGLEEOK4 || i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14641 {
14642 // Some of these are deliberately different to NewDefault/defdata.cpp, by the way. -L
14643 tempguy.misc5 = 4; //neck length in segments
14644 tempguy.misc6 = 8; //neck offset from first body tile
14645 tempguy.misc7 = 40; //offset for each subsequent neck tile from the first neck tile
14646 tempguy.misc8 = 168; //head offset from first body tile
14647 tempguy.misc9 = 228; //flying head offset from first body tile
14648
14649 if(i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14650 {
14651 tempguy.misc6 += 10; //neck offset from first body tile
14652 tempguy.misc8 -= 12; //head offset from first body tile
14653 }
14654 }
14655 }
14656
14657
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(guyversion < 10) // December 2007 - Dodongo CSet fix
14658 {
14659 if(get_bit(deprecated_rules,46) && tempguy.family==eeDONGO && tempguy.misc1==0)
14660 tempguy.bosspal = spDIG;
14661 }
14662
14663
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(guyversion < 11) // December 2007 - Spinning Tile fix
14664 {
14665 if(tempguy.family==eeSPINTILE)
14666 {
14667 tempguy.flags |= guy_superman;
14668 tempguy.item_set = 0; // Don't drop items
14669 tempguy.step = 300;
14670 }
14671 }
14672
14673
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(guyversion < 12) // October 2008 - Flashing Bubble, Rope 2, and Ghini 2 fix
14674 {
14675 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
14676 {
14677 if(tempguy.family==eeROPE)
14678 {
14679 tempguy.flags2 &= ~guy_flashing;
14680 }
14681 }
14682
14683 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
14684 {
14685 if(tempguy.family==eeBUBBLE)
14686 {
14687 tempguy.flags2 &= ~guy_flashing;
14688 }
14689 }
14690
14691 if((tempguy.family==eeGHINI)&&(tempguy.misc1))
14692 {
14693 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
14694 {
14695 tempguy.flags2 |= guy_blinking;
14696 }
14697
14698 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
14699 {
14700 tempguy.flags2 |= guy_transparent;
14701 }
14702 }
14703 }
14704
14705
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(guyversion < 15) // July 2009 - Guy Fire and Fairy fix
14706 {
14707 if(i==gFIRE)
14708 {
14709 tempguy.e_anim = aFLIP;
14710 tempguy.e_frate = 24;
14711 }
14712
14713 if(i==gFAIRY)
14714 {
14715 tempguy.e_anim = a2FRM;
14716 tempguy.e_frate = 16;
14717 }
14718 }
14719
14720
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(guyversion < 16) // November 2009 - Super Enemy Editor part 1
14721 {
14722 if(i==0) Z_message("Updating guys to version 16...\n");
14723
14724 update_guy_1(&tempguy);
14725
14726 if(i==eMPOLSV)
14727 {
14728 tempguy.defense[edefARROW] = edCHINK;
14729 tempguy.defense[edefMAGIC] = ed1HKO;
14730 tempguy.defense[edefREFMAGIC] = ed1HKO;
14731 }
14732 }
14733
14734
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(guyversion < 17) // December 2009
14735 {
14736 if(tempguy.family==eePROJECTILE)
14737 {
14738 tempguy.misc1 = 0;
14739 }
14740 }
14741
14742
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(guyversion < 18) // January 2010
14743 {
14744 bool boss = (tempguy.family == eeAQUA || tempguy.family==eeDONGO || tempguy.family == eeMANHAN || tempguy.family == eeGHOMA || tempguy.family==eeDIG
14745 || tempguy.family == eeGLEEOK || tempguy.family==eePATRA || tempguy.family == eeGANON || tempguy.family==eeMOLD);
14746
14747 tempguy.hitsfx = (boss && tempguy.family != eeMOLD && tempguy.family != eeDONGO && tempguy.family != eeDIG) ? WAV_GASP : 0;
14748 tempguy.deadsfx = (boss && (tempguy.family != eeDIG || tempguy.misc10 == 0)) ? WAV_GASP : WAV_EDEAD;
14749
14750 if(tempguy.family == eeAQUA)
14751 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eRAQUAM].defense[j];
14752 else if(tempguy.family == eeMANHAN)
14753 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eMANHAN].defense[j];
14754 else if(tempguy.family==eePATRA)
14755 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
14756 else if(tempguy.family==eeGHOMA)
14757 {
14758 for(int32_t j=0; j<edefLAST; j++)
14759 tempguy.defense[j] = default_guys[eGOHMA1].defense[j];
14760
14761 tempguy.defense[edefARROW] = ((tempguy.misc1==3) ? edCHINKL8 : (tempguy.misc1==2) ? edCHINKL4 : 0);
14762
14763 if(tempguy.misc1==3 && !tempguy.weapon) tempguy.weapon = ewFlame;
14764
14765 tempguy.misc1--;
14766 }
14767 else if(tempguy.family == eeGLEEOK)
14768 {
14769 for(int32_t j=0; j<edefLAST; j++)
14770 tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
14771
14772 if(tempguy.misc3==1 && !tempguy.weapon) tempguy.weapon = ewFlame;
14773 }
14774 else if(tempguy.family == eeARMOS)
14775 {
14776 tempguy.family=eeWALK;
14777 tempguy.hrate = 0;
14778 tempguy.misc10 = tempguy.misc1;
14779 tempguy.misc1 = tempguy.misc2 = tempguy.misc3 = tempguy.misc4 = tempguy.misc5 = tempguy.misc6 = tempguy.misc7 = tempguy.misc8 = 0;
14780 tempguy.misc9 = e9tARMOS;
14781 }
14782 else if(tempguy.family == eeGHINI && !tempguy.misc1)
14783 {
14784 tempguy.family=eeWALK;
14785 tempguy.hrate = 0;
14786 tempguy.misc1 = tempguy.misc2 = tempguy.misc3 = tempguy.misc4 = tempguy.misc5 = tempguy.misc6 =
14787 tempguy.misc7 = tempguy.misc8 = tempguy.misc9 = tempguy.misc10 = 0;
14788 }
14789
14790 // Spawn animation flags
14791 if(tempguy.family == eeWALK && (tempguy.flags2&cmbflag_armos || tempguy.flags2&cmbflag_ghini))
14792 tempguy.flags |= guy_fadeflicker;
14793 else
14794 tempguy.flags &= 0x0F00000F; // Get rid of the unused flags!
14795 }
14796
14797
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(guyversion < 20) // April 2010
14798 {
14799 if(tempguy.family == eeTRAP)
14800 {
14801 tempguy.misc2 = tempguy.misc10;
14802
14803 if(tempguy.misc10>=1)
14804 {
14805 tempguy.misc1++;
14806 }
14807
14808 tempguy.misc10 = 0;
14809 }
14810
14811 // Bomb Blast fix
14812 if(tempguy.weapon==ewBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.misc2 != e2tBOMBCHU))
14813 tempguy.weapon = ewLitBomb;
14814 else if(tempguy.weapon==ewSBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.misc2 != e2tBOMBCHU))
14815 tempguy.weapon = ewLitSBomb;
14816 }
14817
14818
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(guyversion < 21) // September 2011
14819 {
14820 if(tempguy.family == eeKEESE || tempguy.family == eeKEESETRIB)
14821 {
14822 if(tempguy.family == eeKEESETRIB)
14823 {
14824 tempguy.family = eeKEESE;
14825 tempguy.misc2 = e2tKEESETRIB;
14826 tempguy.misc1 = 0;
14827 }
14828
14829 tempguy.rate = 2;
14830 tempguy.hrate = 8;
14831 tempguy.homing = 0;
14832 tempguy.step= (tempguy.family == eeKEESE && tempguy.misc1 ? 100:62);
14833 }
14834 else if(tempguy.family == eePEAHAT || tempguy.family==eePATRA)
14835 {
14836 if(tempguy.family == eePEAHAT)
14837 {
14838 tempguy.rate = 4;
14839 tempguy.step = 62;
14840 }
14841 else
14842 tempguy.step = 25;
14843
14844 tempguy.hrate = 8;
14845 tempguy.homing = 0;
14846 }
14847 else if(tempguy.family == eeDIG || tempguy.family == eeMANHAN)
14848 {
14849 if(tempguy.family == eeMANHAN)
14850 tempguy.step=50;
14851
14852 tempguy.hrate = 16;
14853 tempguy.homing = 0;
14854 }
14855 else if(tempguy.family == eeGLEEOK)
14856 {
14857 tempguy.rate = 2;
14858 tempguy.homing = 0;
14859 tempguy.hrate = 9;
14860 tempguy.step=89;
14861 }
14862 else if(tempguy.family == eeGHINI)
14863 {
14864 tempguy.rate = 4;
14865 tempguy.hrate = 12;
14866 tempguy.step=62;
14867 tempguy.homing = 0;
14868 }
14869
14870 // Bigdig random rate fix
14871 if(tempguy.family==eeDIG && tempguy.misc10==1)
14872 {
14873 tempguy.rate = 2;
14874 }
14875 }
14876
14877
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(guyversion < 24) // November 2012
14878 {
14879 if(tempguy.family==eeLANM)
14880 tempguy.misc3 = 1;
14881 else if(tempguy.family==eeMOLD)
14882 tempguy.misc2 = 0;
14883 }
14884
14885
2/2
✓ Branch 0 taken 201728 times.
✓ Branch 1 taken 67584 times.
269312 if(guyversion < 33) //Whistle defence did not exist before this version of 2.54. -Z
14886 {
14887
2/2
✓ Branch 0 taken 997 times.
✓ Branch 1 taken 66587 times.
67584 if(tempguy.family!=eeDIG)
14888 {
14889 66587 tempguy.defense[edefWhistle] = edIGNORE; //Might need to be ignore, universally.
14890 66587 }
14891
14892 67584 }
14893 // does not seem to solve the issue!
14894
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if ( Header->zelda_version <= 0x210 )
14895 {
14896 al_trace("Detected version %d for dodongo patch.\n",Header->zelda_version);
14897 if ( tempguy.family == eeDONGO )
14898 {
14899 tempguy.deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
14900 }
14901 }
14902
14903
2/2
✓ Branch 0 taken 201728 times.
✓ Branch 1 taken 67584 times.
269312 if(guyversion >= 42)
14904 {
14905
2/2
✓ Branch 0 taken 199168 times.
✓ Branch 1 taken 2560 times.
201728 if(guyversion >= 47)
14906 {
14907
1/2
✓ Branch 0 taken 199168 times.
✗ Branch 1 not taken.
199168 if(!p_igetl(&(tempguy.moveflags),f))
14908 {
14909 return qe_invalid;
14910 }
14911 199168 }
14912 else
14913 {
14914 byte fl;
14915
1/2
✓ Branch 0 taken 2560 times.
✗ Branch 1 not taken.
2560 if(!p_getc(&fl,f))
14916 {
14917 return qe_invalid;
14918 }
14919 2560 tempguy.moveflags = fl;
14920 }
14921 201728 }
14922 else
14923 {
14924
7/8
✓ Branch 0 taken 1417 times.
✓ Branch 1 taken 53269 times.
✓ Branch 2 taken 1895 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 719 times.
✓ Branch 5 taken 440 times.
✓ Branch 6 taken 361 times.
✓ Branch 7 taken 9483 times.
67584 switch(tempguy.family)
14925 {
14926 //No gravity; floats over pits
14927 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
14928 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
14929 //Special (bosses, etc)
14930 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
14931 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
14932 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
14933 53269 tempguy.moveflags = FLAG_CAN_PITWALK;
14934 53269 break;
14935 //No gravity, but falls in pits
14936 case eeLEV:
14937 719 tempguy.moveflags = FLAG_CAN_PITFALL;
14938 719 break;
14939 //Bosses that respect pits
14940 case eeDONGO:
14941 440 tempguy.moveflags = FLAG_OBEYS_GRAV;
14942 440 break;
14943 case eeLANM:
14944 361 tempguy.moveflags = 0;
14945 361 break;
14946 //Gravity, floats over pits
14947 case eeWIZZ: case eeWALLM: case eeGHINI:
14948 1895 tempguy.moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITWALK;
14949 1895 break;
14950 //Gravity and falls in pits
14951 case eeWALK:
14952
4/4
✓ Branch 0 taken 8991 times.
✓ Branch 1 taken 492 times.
✓ Branch 2 taken 394 times.
✓ Branch 3 taken 8597 times.
9483 if (tempguy.misc9==e9tPOLSVOICE||tempguy.misc9==e9tVIRE)
14953 886 break;
14954 [[fallthrough]];
14955 case eeOTHER:
14956 case eeSCRIPT01: case eeSCRIPT02: case eeSCRIPT03: case eeSCRIPT04: case eeSCRIPT05:
14957 case eeSCRIPT06: case eeSCRIPT07: case eeSCRIPT08: case eeSCRIPT09: case eeSCRIPT10:
14958 case eeSCRIPT11: case eeSCRIPT12: case eeSCRIPT13: case eeSCRIPT14: case eeSCRIPT15:
14959 case eeSCRIPT16: case eeSCRIPT17: case eeSCRIPT18: case eeSCRIPT19: case eeSCRIPT20:
14960 case eeFFRIENDLY01: case eeFFRIENDLY02: case eeFFRIENDLY03: case eeFFRIENDLY04: case eeFFRIENDLY05:
14961 case eeFFRIENDLY06: case eeFFRIENDLY07: case eeFFRIENDLY08: case eeFFRIENDLY09: case eeFFRIENDLY10:
14962 10014 tempguy.moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITFALL;
14963 10014 }
14964 }
14965
2/2
✓ Branch 0 taken 201728 times.
✓ Branch 1 taken 67584 times.
269312 if(guyversion < 43)
14966 {
14967
2/2
✓ Branch 0 taken 55164 times.
✓ Branch 1 taken 12420 times.
67584 switch(tempguy.family)
14968 {
14969 //No gravity; floats over pits
14970 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
14971 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
14972 //Special (bosses, etc)
14973 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
14974 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
14975 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
14976 case eeWIZZ: case eeWALLM: case eeGHINI:
14977 //Gravity, floats over pits
14978 55164 tempguy.moveflags |= FLAG_CAN_WATERWALK;
14979 55164 tempguy.moveflags |= FLAG_CAN_PITWALK;
14980 55164 break;
14981 }
14982 67584 }
14983
2/2
✓ Branch 0 taken 201728 times.
✓ Branch 1 taken 67584 times.
269312 if (guyversion < 44)
14984 {
14985
2/2
✓ Branch 0 taken 66973 times.
✓ Branch 1 taken 611 times.
67584 if ( tempguy.family == eeGHOMA )
14986 {
14987 611 tempguy.flags |= guy_fadeinstant;
14988 611 }
14989 67584 }
14990
2/2
✓ Branch 0 taken 201728 times.
✓ Branch 1 taken 67584 times.
269312 if (guyversion > 44)
14991 {
14992
1/2
✓ Branch 0 taken 201728 times.
✗ Branch 1 not taken.
201728 if(!p_getc(&(tempguy.spr_shadow),f))
14993 {
14994 return qe_invalid;
14995 }
14996
1/2
✓ Branch 0 taken 201728 times.
✗ Branch 1 not taken.
201728 if(!p_getc(&(tempguy.spr_death),f))
14997 {
14998 return qe_invalid;
14999 }
15000
1/2
✓ Branch 0 taken 201728 times.
✗ Branch 1 not taken.
201728 if(!p_getc(&(tempguy.spr_spawn),f))
15001 {
15002 return qe_invalid;
15003 }
15004 201728 }
15005 else
15006 {
15007
2/2
✓ Branch 0 taken 67322 times.
✓ Branch 1 taken 262 times.
67584 tempguy.spr_shadow = (tempguy.family==eeROCK && tempguy.misc10==1) ? iwLargeShadow : iwShadow;
15008 67584 tempguy.spr_death = iwDeath;
15009 67584 tempguy.spr_spawn = iwSpawn;
15010 }
15011
15012
2/2
✓ Branch 0 taken 201728 times.
✓ Branch 1 taken 67584 times.
269312 if(guyversion < 46)
15013 {
15014
4/4
✓ Branch 0 taken 9483 times.
✓ Branch 1 taken 58101 times.
✓ Branch 2 taken 8991 times.
✓ Branch 3 taken 492 times.
67584 if(tempguy.family == eeWALK && tempguy.misc9 == e9tPOLSVOICE)
15015 {
15016 492 tempguy.moveflags |= FLAG_CAN_WATERWALK;
15017 492 }
15018 67584 }
15019
15020
1/2
✓ Branch 0 taken 269312 times.
✗ Branch 1 not taken.
269312 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
15021 {
15022 tempguy.script = 0;
15023 for(int q = 0; q < 8; ++q)
15024 tempguy.initD[q] = 0;
15025 }
15026 269312 guysbuf[i] = tempguy;
15027 269312 }
15028 526 }
15029
15030 526 return 0;
15031 588 }
15032
15033 void update_guy_1(guydata *tempguy) // November 2009
15034 {
15035 bool doesntcount = false;
15036 tempguy->flags &= ~weak_arrow; // Formerly 'weak to arrow' which wasn't implemented
15037
15038 switch(tempguy->family)
15039 {
15040 case 1: //eeWALK
15041 switch(tempguy->misc10)
15042 {
15043 case 0: //Stalfos
15044 if(tempguy->misc1==1) // Fires four projectiles at once
15045 tempguy->misc1=4;
15046
15047 break;
15048
15049 case 1: //Darknut
15050 goto darknuts;
15051 break;
15052 }
15053
15054 tempguy->misc10 = 0;
15055 break;
15056
15057 case 2: //eeSHOOT
15058 tempguy->family = eeWALK;
15059
15060 switch(tempguy->misc10)
15061 {
15062 case 0: //Octorok
15063 if(tempguy->misc1==1||tempguy->misc1==2)
15064 {
15065 tempguy->misc1=e1tFIREOCTO;
15066 tempguy->misc2=e2tFIREOCTO;
15067 }
15068 else tempguy->misc1 = 0;
15069
15070 tempguy->misc6=tempguy->misc4;
15071 tempguy->misc4=tempguy->misc3;
15072 tempguy->misc3=0;
15073 break;
15074
15075 case 1: // Moblin
15076 tempguy->misc1 = 0;
15077 break;
15078
15079 case 2: //Lynel
15080 tempguy->misc6=tempguy->misc1+1;
15081 tempguy->misc1=0;
15082 break;
15083
15084 case 3: //Stalfos 2
15085 if(tempguy->misc1==1) // Fires four projectiles at once
15086 tempguy->misc1=e1t4SHOTS;
15087 else tempguy->misc1 = 0;
15088
15089 break;
15090
15091 case 4: //Darknut 5
15092 darknuts:
15093 tempguy->defense[edefFIRE] = edIGNORE;
15094 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15095 tempguy->defense[edefHOOKSHOT] = 0;
15096 tempguy->defense[edefARROW] = tempguy->defense[edefBYRNA] = tempguy->defense[edefREFROCK] =
15097 tempguy->defense[edefMAGIC] = tempguy->defense[edefSTOMP] = edCHINK;
15098
15099 if(tempguy->misc1==1)
15100 tempguy->misc1=2;
15101 else if(tempguy->misc1==2)
15102 {
15103 tempguy->misc4=tempguy->misc3;
15104 tempguy->misc3=tempguy->misc2;
15105 tempguy->misc2=e2tSPLIT;
15106 tempguy->misc1 = 0;
15107 }
15108 else tempguy->misc1 = 0;
15109
15110 tempguy->flags |= inv_front;
15111
15112 if(get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
15113 tempguy->flags |= guy_bkshield;
15114
15115 break;
15116 }
15117
15118 tempguy->misc10 = 0;
15119 break;
15120
15121 /*
15122 case 9: //eeARMOS
15123 tempguy->family = eeWALK;
15124 break;
15125 */
15126 case 11: //eeGEL
15127 case 33: //eeGELTRIB
15128 if(tempguy->family==33)
15129 {
15130 tempguy->misc4 = 1;
15131
15132 if(get_bit(deprecated_rules, qr_OLDTRIBBLES_DEP)) //Old Tribbles
15133 tempguy->misc3 = tempguy->misc2;
15134
15135 tempguy->misc2 = e2tTRIBBLE;
15136 }
15137 else
15138 {
15139 tempguy->misc4 = 0;
15140 tempguy->misc3 = 0;
15141 tempguy->misc2 = 0;
15142 }
15143
15144 tempguy->family = eeWALK;
15145
15146 if(tempguy->misc1)
15147 {
15148 tempguy->misc1=1;
15149 tempguy->weapon = ewFireTrail;
15150 }
15151
15152 break;
15153
15154 case 34: //eeZOLTRIB
15155 case 12: //eeZOL
15156 tempguy->misc4=tempguy->misc3;
15157 tempguy->misc3=tempguy->misc2;
15158 tempguy->family = eeWALK;
15159 tempguy->misc2=e2tSPLITHIT;
15160
15161 if(tempguy->misc1)
15162 {
15163 tempguy->misc1=1;
15164 tempguy->weapon = ewFireTrail;
15165 }
15166
15167 break;
15168
15169 case 13: //eeROPE
15170 tempguy->family = eeWALK;
15171 tempguy->misc9 = e9tROPE;
15172
15173 if(tempguy->misc1)
15174 {
15175 tempguy->misc4 = tempguy->misc3;
15176 tempguy->misc3 = tempguy->misc2;
15177 tempguy->misc2 = e2tBOMBCHU;
15178 }
15179
15180 tempguy->misc1 = 0;
15181 break;
15182
15183 case 14: //eeGORIYA
15184 tempguy->family = eeWALK;
15185
15186 if(tempguy->misc1!=2) tempguy->misc1 = 0;
15187
15188 break;
15189
15190 case 17: //eeBUBBLE
15191 tempguy->family = eeWALK;
15192 tempguy->misc8 = tempguy->misc2;
15193 tempguy->misc7 = tempguy->misc1 + 1;
15194 tempguy->misc1 = tempguy->misc2 = 0;
15195
15196 //fallthrogh
15197 case eeTRAP:
15198 case eeROCK:
15199 doesntcount = true;
15200 break;
15201
15202 case 35: //eeVIRETRIB
15203 case 18: //eeVIRE
15204 tempguy->family = eeWALK;
15205 tempguy->misc4=tempguy->misc3;
15206 tempguy->misc3=tempguy->misc2;
15207 tempguy->misc2=e2tSPLITHIT;
15208 tempguy->misc9=e9tVIRE;
15209 break;
15210
15211 case 19: //eeLIKE
15212 tempguy->family = eeWALK;
15213 tempguy->misc7 = e7tEATITEMS;
15214 tempguy->misc8=95;
15215 break;
15216
15217 case 20: //eePOLSV
15218 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15219 tempguy->defense[edefBOMB] = tempguy->defense[edefSBOMB] = tempguy->defense[edefFIRE] = edIGNORE;
15220 tempguy->defense[edefMAGIC] = tempguy->defense[edefBYRNA] = edCHINK;
15221 tempguy->defense[edefARROW] = ed1HKO;
15222 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15223 tempguy->family = eeWALK;
15224 tempguy->misc9 = e9tPOLSVOICE;
15225 tempguy->rate = 4;
15226 tempguy->homing = 32;
15227 tempguy->hrate = 10;
15228 tempguy->grumble = 0;
15229 break;
15230
15231 case eeWIZZ:
15232 if(tempguy->misc4)
15233 {
15234 for(int32_t i=0; i < edefLAST; i++)
15235 tempguy->defense[i] = (i != edefREFBEAM && i != edefREFMAGIC && i != edefQUAKE) ? edIGNORE : 0;
15236 }
15237 else
15238 {
15239 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15240 tempguy->defense[edefMAGIC] = edCHINK;
15241 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15242 tempguy->defense[edefARROW] = tempguy->defense[edefFIRE] =
15243 tempguy->defense[edefWAND] = tempguy->defense[edefBYRNA] = edIGNORE;
15244 }
15245
15246 break;
15247
15248 case eePEAHAT:
15249 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15250
15251 if(!(tempguy->flags & guy_bhit))
15252 tempguy->defense[edefBRANG] = edSTUNONLY;
15253
15254 break;
15255
15256 case eeLEV:
15257 tempguy->defense[edefSTOMP] = edCHINK;
15258 break;
15259 }
15260
15261 // Old flags
15262 if(tempguy->flags & guy_superman)
15263 {
15264 for(int32_t i = 0; i < edefLAST; i++)
15265 if(!(i==edefSBOMB && (tempguy->flags & guy_sbombonly)))
15266 tempguy->defense[i] = (i==edefBRANG && tempguy->defense[i] != edIGNORE
15267 && tempguy->family != eeROCK && tempguy->family != eeTRAP
15268 && tempguy->family != eePROJECTILE) ? edSTUNORIGNORE : edIGNORE;
15269 }
15270
15271 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15272
15273 if(doesntcount)
15274 tempguy->flags |= (guy_doesntcount);
15275 }
15276
15277
15278 714960 int32_t readmapscreen_old(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, word version)
15279 {
15280 byte tempbyte, padding;
15281 int32_t extras, secretcombos;
15282 //al_trace("readmapscreen Header->zelda_version: %x\n",Header->zelda_version);
15283
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 714960 times.
714960 if(!p_getc(&(temp_mapscr->valid),f))
15284 {
15285 return qe_invalid;
15286 }
15287
15288
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 714960 times.
714960 if(!p_getc(&(temp_mapscr->guy),f))
15289 return qe_invalid;
15290 714960 temp_mapscr->guytile = -1; //signal to use default guy values
15291
2/2
✓ Branch 0 taken 714393 times.
✓ Branch 1 taken 567 times.
714960 SETFLAG(temp_mapscr->roomflags,RFL_ALWAYS_GUY,temp_mapscr->guy==gFAIRY);
15292
4/4
✓ Branch 0 taken 567 times.
✓ Branch 1 taken 714393 times.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 529 times.
714960 SETFLAG(temp_mapscr->roomflags,RFL_GUYFIRES,temp_mapscr->guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES));
15293
15294
5/6
✓ Branch 0 taken 692784 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 690064 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
714960 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<146)))
15295 {
15296
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22176 times.
22176 if(!p_getc(&tempbyte,f))
15297 {
15298 return qe_invalid;
15299 }
15300
15301 22176 temp_mapscr->str=tempbyte;
15302 22176 }
15303 else
15304 {
15305
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 692784 times.
692784 if(!p_igetw(&(temp_mapscr->str),f))
15306 {
15307 return qe_invalid;
15308 }
15309 }
15310
15311
1/2
✓ Branch 0 taken 714960 times.
✗ Branch 1 not taken.
714960 if(!p_getc(&(temp_mapscr->room),f))
15312 {
15313 return qe_invalid;
15314 }
15315
15316
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 714960 times.
714960 if(!p_getc(&(temp_mapscr->item),f))
15317 {
15318 return qe_invalid;
15319 }
15320
15321
3/6
✓ Branch 0 taken 378760 times.
✓ Branch 1 taken 336200 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 378760 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
714960 if(Header->zelda_version < 0x211 || (Header->zelda_version == 0x211 && Header->build < 14))
15322 {
15323 336200 temp_mapscr->hasitem = (temp_mapscr->item != 0) ? 1 : 0;
15324 336200 }
15325 else
15326 {
15327
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 378760 times.
378760 if(!p_getc(&(temp_mapscr->hasitem),f))
15328 return qe_invalid;
15329 }
15330
15331
3/4
✓ Branch 0 taken 692784 times.
✓ Branch 1 taken 22176 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
717680 if((Header->zelda_version < 0x192)||
15332
2/2
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 690064 times.
692784 ((Header->zelda_version == 0x192)&&(Header->build<154)))
15333 {
15334
1/2
✓ Branch 0 taken 22176 times.
✗ Branch 1 not taken.
22176 if(!p_getc(&tempbyte,f))
15335 {
15336 return qe_invalid;
15337 }
15338 22176 }
15339
15340
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 714960 times.
714960 if(!p_getc(&(temp_mapscr->tilewarptype[0]),f))
15341 {
15342 return qe_invalid;
15343 }
15344
15345
2/2
✓ Branch 0 taken 690064 times.
✓ Branch 1 taken 24896 times.
714960 if(Header->zelda_version < 0x193)
15346 {
15347
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24896 times.
24896 if(!p_getc(&tempbyte,f))
15348 {
15349 return qe_invalid;
15350 }
15351 24896 }
15352
15353
3/6
✓ Branch 0 taken 336200 times.
✓ Branch 1 taken 378760 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 336200 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
714960 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15354 {
15355
2/2
✓ Branch 0 taken 1136280 times.
✓ Branch 1 taken 378760 times.
1515040 for(int32_t i=1; i<4; i++)
15356 {
15357
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1136280 times.
1136280 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f))
15358 {
15359 return qe_invalid;
15360 }
15361 1136280 }
15362 378760 }
15363 else
15364 {
15365 336200 temp_mapscr->tilewarptype[1]=0;
15366 336200 temp_mapscr->tilewarptype[2]=0;
15367 336200 temp_mapscr->tilewarptype[3]=0;
15368 }
15369
15370
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 690064 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
714960 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
15371 {
15372
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 692784 times.
692784 if(!p_igetw(&(temp_mapscr->door_combo_set),f))
15373 {
15374 return qe_invalid;
15375 }
15376 692784 }
15377
15378
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 714960 times.
714960 if(!p_getc(&(temp_mapscr->warpreturnx[0]),f))
15379 {
15380 return qe_invalid;
15381 }
15382
15383 714960 temp_mapscr->warpreturnx[1]=0;
15384 714960 temp_mapscr->warpreturnx[2]=0;
15385 714960 temp_mapscr->warpreturnx[3]=0;
15386
15387
3/6
✓ Branch 0 taken 336200 times.
✓ Branch 1 taken 378760 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 336200 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
714960 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15388 {
15389
2/2
✓ Branch 0 taken 1136280 times.
✓ Branch 1 taken 378760 times.
1515040 for(int32_t i=1; i<4; i++)
15390 {
15391
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1136280 times.
1136280 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f))
15392 {
15393 return qe_invalid;
15394 }
15395 1136280 }
15396 378760 }
15397
15398
1/2
✓ Branch 0 taken 714960 times.
✗ Branch 1 not taken.
714960 if(!p_getc(&(temp_mapscr->warpreturny[0]),f))
15399 {
15400 return qe_invalid;
15401 }
15402
15403 714960 temp_mapscr->warpreturny[1]=0;
15404 714960 temp_mapscr->warpreturny[2]=0;
15405 714960 temp_mapscr->warpreturny[3]=0;
15406
15407
3/6
✓ Branch 0 taken 336200 times.
✓ Branch 1 taken 378760 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 336200 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
714960 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15408 {
15409
2/2
✓ Branch 0 taken 1136280 times.
✓ Branch 1 taken 378760 times.
1515040 for(int32_t i=1; i<4; i++)
15410 {
15411
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1136280 times.
1136280 if(!p_getc(&(temp_mapscr->warpreturny[i]),f))
15412 {
15413 return qe_invalid;
15414 }
15415 1136280 }
15416
15417
1/2
✓ Branch 0 taken 378760 times.
✗ Branch 1 not taken.
378760 if(version>=18)
15418 {
15419
1/2
✓ Branch 0 taken 378760 times.
✗ Branch 1 not taken.
378760 if(!p_igetw(&temp_mapscr->warpreturnc,f))
15420 {
15421 return qe_invalid;
15422 }
15423 378760 }
15424 else
15425 {
15426 byte temp;
15427
15428 if(!p_getc(&temp,f))
15429 {
15430 return qe_invalid;
15431 }
15432
15433 temp_mapscr->warpreturnc=temp<<8|temp;
15434 }
15435 378760 }
15436
15437
1/2
✓ Branch 0 taken 714960 times.
✗ Branch 1 not taken.
714960 if(!p_getc(&(temp_mapscr->stairx),f))
15438
15439 {
15440 return qe_invalid;
15441 }
15442
15443
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 714960 times.
714960 if(!p_getc(&(temp_mapscr->stairy),f))
15444 {
15445 return qe_invalid;
15446 }
15447
15448
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 714960 times.
714960 if(!p_getc(&(temp_mapscr->itemx),f))
15449 {
15450 return qe_invalid;
15451 }
15452
15453
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 714960 times.
714960 if(!p_getc(&(temp_mapscr->itemy),f))
15454 {
15455 return qe_invalid;
15456 }
15457
15458
2/2
✓ Branch 0 taken 378760 times.
✓ Branch 1 taken 336200 times.
714960 if(version > 15) // February 2009
15459 {
15460
1/2
✓ Branch 0 taken 378760 times.
✗ Branch 1 not taken.
378760 if(!p_igetw(&(temp_mapscr->color),f))
15461 {
15462 return qe_invalid;
15463 }
15464 378760 }
15465 else
15466 {
15467
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 336200 times.
336200 if(!p_getc(& tempbyte,f))
15468 {
15469 return qe_invalid;
15470 }
15471
15472 336200 temp_mapscr->color = (word) tempbyte;
15473 }
15474
15475
1/2
✓ Branch 0 taken 714960 times.
✗ Branch 1 not taken.
714960 if(!p_getc(&(temp_mapscr->enemyflags),f))
15476 {
15477 return qe_invalid;
15478 }
15479
15480
2/2
✓ Branch 0 taken 2859840 times.
✓ Branch 1 taken 714960 times.
3574800 for(int32_t k=0; k<4; k++)
15481 {
15482
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2859840 times.
2859840 if(!p_getc(&(temp_mapscr->door[k]),f))
15483 {
15484 return qe_invalid;
15485
15486 }
15487 2859840 }
15488
15489
2/2
✓ Branch 0 taken 336200 times.
✓ Branch 1 taken 378760 times.
714960 if(version <= 11)
15490 {
15491
1/2
✓ Branch 0 taken 336200 times.
✗ Branch 1 not taken.
336200 if(!p_getc(&(tempbyte),f))
15492 {
15493 return qe_invalid;
15494 }
15495
15496 336200 temp_mapscr->tilewarpdmap[0]=(word)tempbyte;
15497
15498
2/6
✓ Branch 0 taken 336200 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 336200 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
336200 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15499 {
15500 for(int32_t i=1; i<4; i++)
15501 {
15502 if(!p_getc(&(tempbyte),f))
15503 {
15504 return qe_invalid;
15505 }
15506
15507 temp_mapscr->tilewarpdmap[i]=(word)tempbyte;
15508 }
15509 }
15510 else
15511 {
15512 336200 temp_mapscr->tilewarpdmap[1]=0;
15513 336200 temp_mapscr->tilewarpdmap[2]=0;
15514 336200 temp_mapscr->tilewarpdmap[3]=0;
15515 }
15516 336200 }
15517 else
15518 {
15519
2/2
✓ Branch 0 taken 1515040 times.
✓ Branch 1 taken 378760 times.
1893800 for(int32_t i=0; i<4; i++)
15520 {
15521
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1515040 times.
1515040 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f))
15522 {
15523 return qe_invalid;
15524 }
15525 1515040 }
15526 }
15527
15528
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 714960 times.
714960 if(!p_getc(&(temp_mapscr->tilewarpscr[0]),f))
15529 {
15530 return qe_invalid;
15531 }
15532
15533
3/6
✓ Branch 0 taken 336200 times.
✓ Branch 1 taken 378760 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 336200 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
714960 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15534 {
15535
2/2
✓ Branch 0 taken 1136280 times.
✓ Branch 1 taken 378760 times.
1515040 for(int32_t i=1; i<4; i++)
15536 {
15537
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1136280 times.
1136280 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f))
15538 {
15539 return qe_invalid;
15540 }
15541 1136280 }
15542 378760 }
15543 else
15544 {
15545 336200 temp_mapscr->tilewarpscr[1]=0;
15546 336200 temp_mapscr->tilewarpscr[2]=0;
15547 336200 temp_mapscr->tilewarpscr[3]=0;
15548 }
15549
15550
2/2
✓ Branch 0 taken 378760 times.
✓ Branch 1 taken 336200 times.
714960 if(version >= 15)
15551 {
15552
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 378760 times.
378760 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f))
15553 {
15554 return qe_invalid;
15555 }
15556 378760 }
15557 else
15558 {
15559 336200 temp_mapscr->tilewarpoverlayflags=0;
15560 }
15561
15562
1/2
✓ Branch 0 taken 714960 times.
✗ Branch 1 not taken.
714960 if(!p_getc(&(temp_mapscr->exitdir),f))
15563 {
15564 return qe_invalid;
15565 }
15566
15567
2/2
✓ Branch 0 taken 690064 times.
✓ Branch 1 taken 24896 times.
714960 if(Header->zelda_version < 0x193)
15568 {
15569
1/2
✓ Branch 0 taken 24896 times.
✗ Branch 1 not taken.
24896 if(!p_getc(&tempbyte,f))
15570 {
15571 return qe_invalid;
15572 }
15573
15574 24896 }
15575
15576
4/6
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 712240 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
714960 if((Header->zelda_version == 0x192)&&(Header->build>145)&&(Header->build<154))
15577 {
15578 if(!p_getc(&padding,f))
15579 {
15580 return qe_invalid;
15581 }
15582 }
15583
15584
2/2
✓ Branch 0 taken 7149600 times.
✓ Branch 1 taken 714960 times.
7864560 for(int32_t k=0; k<10; k++)
15585 {
15586 /*
15587 if (!temp_mapscr->enemy[k])
15588 {
15589 continue;
15590 }
15591 */
15592
5/6
✓ Branch 0 taken 6927840 times.
✓ Branch 1 taken 221760 times.
✓ Branch 2 taken 27200 times.
✓ Branch 3 taken 6900640 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 27200 times.
7149600 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<10)))
15593 {
15594
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 221760 times.
221760 if(!p_getc(&tempbyte,f))
15595 {
15596 return qe_invalid;
15597 }
15598
15599 221760 temp_mapscr->enemy[k]=tempbyte;
15600 221760 }
15601 else
15602 {
15603
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6927840 times.
6927840 if(!p_igetw(&(temp_mapscr->enemy[k]),f))
15604 {
15605 return qe_invalid;
15606 }
15607 }
15608
15609
5/6
✓ Branch 0 taken 6927840 times.
✓ Branch 1 taken 221760 times.
✓ Branch 2 taken 27200 times.
✓ Branch 3 taken 6900640 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 27200 times.
7149600 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<108)))
15610 {
15611 //using enumerations here is dangerous
15612 //very easy to break old quests -DD
15613
2/2
✓ Branch 0 taken 1342 times.
✓ Branch 1 taken 220418 times.
221760 if(temp_mapscr->enemy[k]>=57) //old eGOHMA1
15614 {
15615 1342 temp_mapscr->enemy[k]+=5;
15616 1342 }
15617
2/2
✓ Branch 0 taken 220324 times.
✓ Branch 1 taken 94 times.
220418 else if(temp_mapscr->enemy[k]>=52) //old eGLEEOK2
15618 {
15619 94 temp_mapscr->enemy[k]+=1;
15620 94 }
15621 221760 }
15622
15623
2/2
✓ Branch 0 taken 3787600 times.
✓ Branch 1 taken 3362000 times.
7149600 if(version < 9)
15624 {
15625
2/2
✓ Branch 0 taken 3170071 times.
✓ Branch 1 taken 191929 times.
3362000 if(temp_mapscr->enemy[k]>0)
15626 {
15627 191929 temp_mapscr->enemy[k]+=10;
15628 191929 }
15629 3362000 }
15630 //don't read in any invalid data
15631
2/2
✓ Branch 0 taken 7149320 times.
✓ Branch 1 taken 280 times.
7149600 if ( ((unsigned)temp_mapscr->enemy[k]) > MAXGUYS )
15632 {
15633 280 al_trace("Tried to read an invalid enemy ID (%d) for tmpscr->enemy[%d]. This has been cleared to 0.\n", temp_mapscr->enemy[k], k);
15634 280 temp_mapscr->enemy[k] = 0;
15635 280 }
15636 7149600 }
15637
15638
1/2
✓ Branch 0 taken 714960 times.
✗ Branch 1 not taken.
714960 if(!p_getc(&(temp_mapscr->pattern),f))
15639 {
15640 return qe_invalid;
15641 }
15642
15643
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 714960 times.
714960 if(!p_getc(&(temp_mapscr->sidewarptype[0]),f))
15644 {
15645 return qe_invalid;
15646 }
15647
15648
3/6
✓ Branch 0 taken 336200 times.
✓ Branch 1 taken 378760 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 336200 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
714960 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15649 {
15650
2/2
✓ Branch 0 taken 1136280 times.
✓ Branch 1 taken 378760 times.
1515040 for(int32_t i=1; i<4; i++)
15651 {
15652
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1136280 times.
1136280 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f))
15653 {
15654 return qe_invalid;
15655 }
15656 1136280 }
15657 378760 }
15658 else
15659 {
15660 336200 temp_mapscr->sidewarptype[1]=0;
15661 336200 temp_mapscr->sidewarptype[2]=0;
15662 336200 temp_mapscr->sidewarptype[3]=0;
15663 }
15664
15665
2/2
✓ Branch 0 taken 378760 times.
✓ Branch 1 taken 336200 times.
714960 if(version >= 15)
15666 {
15667
1/2
✓ Branch 0 taken 378760 times.
✗ Branch 1 not taken.
378760 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f))
15668 {
15669 return qe_invalid;
15670 }
15671 378760 }
15672 else
15673 {
15674 336200 temp_mapscr->sidewarpoverlayflags=0;
15675 }
15676
15677
1/2
✓ Branch 0 taken 714960 times.
✗ Branch 1 not taken.
714960 if(!p_getc(&(temp_mapscr->warparrivalx),f))
15678 {
15679 return qe_invalid;
15680 }
15681
15682
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 714960 times.
714960 if(!p_getc(&(temp_mapscr->warparrivaly),f))
15683 {
15684 return qe_invalid;
15685 }
15686
15687
2/2
✓ Branch 0 taken 2859840 times.
✓ Branch 1 taken 714960 times.
3574800 for(int32_t k=0; k<4; k++)
15688 {
15689
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2859840 times.
2859840 if(!p_getc(&(temp_mapscr->path[k]),f))
15690 {
15691 return qe_invalid;
15692 }
15693 2859840 }
15694
15695
1/2
✓ Branch 0 taken 714960 times.
✗ Branch 1 not taken.
714960 if(!p_getc(&(temp_mapscr->sidewarpscr[0]),f))
15696 {
15697 return qe_invalid;
15698 }
15699
15700
3/6
✓ Branch 0 taken 336200 times.
✓ Branch 1 taken 378760 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 336200 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
714960 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15701 {
15702
2/2
✓ Branch 0 taken 378760 times.
✓ Branch 1 taken 1136280 times.
1515040 for(int32_t i=1; i<4; i++)
15703 {
15704
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1136280 times.
1136280 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f))
15705 {
15706 return qe_invalid;
15707 }
15708 1136280 }
15709 378760 }
15710 else
15711 {
15712 336200 temp_mapscr->sidewarpscr[1]=0;
15713 336200 temp_mapscr->sidewarpscr[2]=0;
15714 336200 temp_mapscr->sidewarpscr[3]=0;
15715 }
15716
15717
2/2
✓ Branch 0 taken 336200 times.
✓ Branch 1 taken 378760 times.
714960 if(version <= 11)
15718 {
15719
1/2
✓ Branch 0 taken 336200 times.
✗ Branch 1 not taken.
336200 if(!p_getc(&(tempbyte),f))
15720 {
15721 return qe_invalid;
15722 }
15723
15724 336200 temp_mapscr->sidewarpdmap[0]=(word)tempbyte;
15725
15726
2/6
✓ Branch 0 taken 336200 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 336200 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
336200 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15727 {
15728 for(int32_t i=1; i<4; i++)
15729 {
15730 if(!p_getc(&(tempbyte),f))
15731 {
15732 return qe_invalid;
15733 }
15734
15735 temp_mapscr->sidewarpdmap[i]=(word)tempbyte;
15736 }
15737 }
15738 else
15739 {
15740 336200 temp_mapscr->sidewarpdmap[1]=0;
15741 336200 temp_mapscr->sidewarpdmap[2]=0;
15742 336200 temp_mapscr->sidewarpdmap[3]=0;
15743 }
15744 336200 }
15745 else
15746 {
15747
2/2
✓ Branch 0 taken 1515040 times.
✓ Branch 1 taken 378760 times.
1893800 for(int32_t i=0; i<4; i++)
15748 {
15749
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1515040 times.
1515040 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f))
15750 {
15751 return qe_invalid;
15752 }
15753 1515040 }
15754 }
15755
15756
3/6
✓ Branch 0 taken 336200 times.
✓ Branch 1 taken 378760 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 336200 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
714960 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15757 {
15758
1/2
✓ Branch 0 taken 378760 times.
✗ Branch 1 not taken.
378760 if(!p_getc(&(temp_mapscr->sidewarpindex),f))
15759 {
15760 return qe_invalid;
15761 }
15762 378760 }
15763 336200 else temp_mapscr->sidewarpindex = 0;
15764
15765
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 714960 times.
714960 if(!p_igetw(&(temp_mapscr->undercombo),f))
15766 {
15767 return qe_invalid;
15768 }
15769
15770
2/2
✓ Branch 0 taken 690064 times.
✓ Branch 1 taken 24896 times.
714960 if(Header->zelda_version < 0x193)
15771 {
15772
1/2
✓ Branch 0 taken 24896 times.
✗ Branch 1 not taken.
24896 if(!p_getc(&(temp_mapscr->old_cpage),f))
15773 {
15774 return qe_invalid;
15775 }
15776 24896 }
15777
15778
1/2
✓ Branch 0 taken 714960 times.
✗ Branch 1 not taken.
714960 if(!p_getc(&(temp_mapscr->undercset),f)) //recalculated for older quests
15779 {
15780 return qe_invalid;
15781 }
15782
15783
1/2
✓ Branch 0 taken 714960 times.
✗ Branch 1 not taken.
714960 if(!p_igetw(&(temp_mapscr->catchall),f))
15784 {
15785 return qe_invalid;
15786 }
15787
15788
1/2
✓ Branch 0 taken 714960 times.
✗ Branch 1 not taken.
714960 if(!p_getc(&(temp_mapscr->flags),f))
15789 {
15790 return qe_invalid;
15791 }
15792
15793
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 714960 times.
714960 if(!p_getc(&(temp_mapscr->flags2),f))
15794 {
15795 return qe_invalid;
15796 }
15797
15798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 714960 times.
714960 if(!p_getc(&(temp_mapscr->flags3),f))
15799 {
15800 return qe_invalid;
15801 }
15802
15803
3/6
✓ Branch 0 taken 336200 times.
✓ Branch 1 taken 378760 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 336200 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
714960 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>1)))
15804 //if (version>2)
15805 {
15806
1/2
✓ Branch 0 taken 378760 times.
✗ Branch 1 not taken.
378760 if(!p_getc(&(temp_mapscr->flags4),f))
15807 {
15808 return qe_invalid;
15809 }
15810 378760 }
15811
15812
3/6
✓ Branch 0 taken 336200 times.
✓ Branch 1 taken 378760 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 336200 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
714960 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15813 {
15814
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 378760 times.
378760 if(!p_getc(&(temp_mapscr->flags5),f))
15815 {
15816 return qe_invalid;
15817 }
15818
15819
1/2
✓ Branch 0 taken 378760 times.
✗ Branch 1 not taken.
378760 if(!p_igetw(&(temp_mapscr->noreset),f))
15820 {
15821 return qe_invalid;
15822 }
15823
15824
1/2
✓ Branch 0 taken 378760 times.
✗ Branch 1 not taken.
378760 if(!p_igetw(&(temp_mapscr->nocarry),f))
15825 {
15826 return qe_invalid;
15827 }
15828
15829
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 378760 times.
378760 if(temp_mapscr->flags5&32)
15830 {
15831 temp_mapscr->flags5 &= ~32;
15832 temp_mapscr->noreset |= 48;
15833 }
15834
15835
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 378760 times.
378760 if(version<8)
15836 {
15837 if(temp_mapscr->noreset&1)
15838 {
15839 temp_mapscr->noreset|=8192;
15840 }
15841
15842 if(temp_mapscr->nocarry&1)
15843 {
15844 temp_mapscr->nocarry|=8192;
15845 temp_mapscr->nocarry&=~1;
15846 }
15847 }
15848 378760 }
15849 else
15850 {
15851 336200 temp_mapscr->flags5 = 0;
15852 336200 temp_mapscr->noreset = 0;
15853 336200 temp_mapscr->nocarry = 0;
15854 }
15855
15856
3/6
✓ Branch 0 taken 336200 times.
✓ Branch 1 taken 378760 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 336200 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
714960 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>9)))
15857 {
15858
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 378760 times.
378760 if(!p_getc(&(temp_mapscr->flags6),f))
15859 {
15860 return qe_invalid;
15861 }
15862 378760 }
15863
15864
2/2
✓ Branch 0 taken 378760 times.
✓ Branch 1 taken 336200 times.
714960 if(version>5)
15865 {
15866
1/2
✓ Branch 0 taken 378760 times.
✗ Branch 1 not taken.
378760 if(!p_getc(&(temp_mapscr->flags7),f))
15867 {
15868 return qe_invalid;
15869 }
15870
15871
1/2
✓ Branch 0 taken 378760 times.
✗ Branch 1 not taken.
378760 if(!p_getc(&(temp_mapscr->flags8),f))
15872 {
15873 return qe_invalid;
15874 }
15875
15876
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 378760 times.
378760 if(!p_getc(&(temp_mapscr->flags9),f))
15877 {
15878 return qe_invalid;
15879 }
15880
15881
1/2
✓ Branch 0 taken 378760 times.
✗ Branch 1 not taken.
378760 if(!p_getc(&(temp_mapscr->flags10),f))
15882 {
15883 return qe_invalid;
15884 }
15885
15886
1/2
✓ Branch 0 taken 378760 times.
✗ Branch 1 not taken.
378760 if(!p_getc(&(temp_mapscr->csensitive),f))
15887 {
15888 return qe_invalid;
15889 }
15890 378760 }
15891 else
15892 {
15893 336200 temp_mapscr->csensitive=1;
15894 }
15895
15896
2/2
✓ Branch 0 taken 336200 times.
✓ Branch 1 taken 378760 times.
714960 if(version<14) // August 2007: screen SFX added
15897 {
15898
2/2
✓ Branch 0 taken 335528 times.
✓ Branch 1 taken 672 times.
336200 if(temp_mapscr->flags&8) //fROAR
15899 {
15900 672 temp_mapscr->bosssfx=
15901
2/2
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 582 times.
672 (temp_mapscr->flags3&2) ? WAV_DODONGO : // fDODONGO
15902 582 (temp_mapscr->flags2&32) ? WAV_VADER : // fVADER
15903 WAV_ROAR;
15904 672 }
15905
15906
2/2
✓ Branch 0 taken 170 times.
✓ Branch 1 taken 336030 times.
336200 if(temp_mapscr->flags&128) //fSEA
15907 {
15908 170 temp_mapscr->oceansfx=WAV_SEA;
15909 170 }
15910
15911 336200 temp_mapscr->secretsfx = (temp_mapscr->flags3&64) //fNOSECRETSOUND
15912 ? 0 : WAV_SECRET;
15913
15914 336200 temp_mapscr->flags3 &= ~66; //64|2
15915 336200 temp_mapscr->flags2 &= ~32;
15916 336200 temp_mapscr->flags &= ~136; // 128|8
15917 336200 }
15918 else
15919 {
15920
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 378760 times.
378760 if(!p_getc(&(temp_mapscr->oceansfx),f))
15921 {
15922 return qe_invalid;
15923 }
15924
15925
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 378760 times.
378760 if(!p_getc(&(temp_mapscr->bosssfx),f))
15926 {
15927 return qe_invalid;
15928 }
15929
15930
1/2
✓ Branch 0 taken 378760 times.
✗ Branch 1 not taken.
378760 if(!p_getc(&(temp_mapscr->secretsfx),f))
15931 {
15932 return qe_invalid;
15933 }
15934 }
15935
15936
2/2
✓ Branch 0 taken 336200 times.
✓ Branch 1 taken 378760 times.
714960 if(version<15) // October 2007: another SFX
15937 {
15938 336200 temp_mapscr->holdupsfx=WAV_PICKUP;
15939 336200 }
15940 else
15941 {
15942
1/2
✓ Branch 0 taken 378760 times.
✗ Branch 1 not taken.
378760 if(!p_getc(&(temp_mapscr->holdupsfx),f))
15943 {
15944 return qe_invalid;
15945 }
15946 }
15947
15948
15949
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 690064 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
714960 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
15950 {
15951
2/2
✓ Branch 0 taken 4156704 times.
✓ Branch 1 taken 692784 times.
4849488 for(int32_t k=0; k<6; k++)
15952 {
15953
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4156704 times.
4156704 if(!p_getc(&(temp_mapscr->layermap[k]),f))
15954 {
15955 return qe_invalid;
15956 }
15957 4156704 }
15958
15959
2/2
✓ Branch 0 taken 692784 times.
✓ Branch 1 taken 4156704 times.
4849488 for(int32_t k=0; k<6; k++)
15960 {
15961
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4156704 times.
4156704 if(!p_getc(&(temp_mapscr->layerscreen[k]),f))
15962 {
15963 return qe_invalid;
15964 }
15965 4156704 }
15966 692784 }
15967
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 22176 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
22176 else if((Header->zelda_version == 0x192)&&(Header->build>23)&&(Header->build<98))
15968 {
15969 if(!p_getc(&(temp_mapscr->layermap[2]),f))
15970 {
15971 return qe_invalid;
15972 }
15973
15974 if(!p_getc(&(temp_mapscr->layerscreen[2]),f))
15975 {
15976 return qe_invalid;
15977 }
15978
15979 if(!p_getc(&(temp_mapscr->layermap[4]),f))
15980 {
15981 return qe_invalid;
15982 }
15983
15984 if(!p_getc(&(temp_mapscr->layerscreen[4]),f))
15985
15986 {
15987 return qe_invalid;
15988 }
15989 }
15990
15991
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 712240 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
714960 if((Header->zelda_version == 0x192)&&(Header->build>149))
15992 {
15993
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
15994 {
15995
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerxsize
15996 {
15997 return qe_invalid;
15998 }
15999 16320 }
16000
16001
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16002 {
16003
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerxspeed
16004 {
16005 return qe_invalid;
16006 }
16007 16320 }
16008
16009
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16010 {
16011
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerxdelay
16012 {
16013 return qe_invalid;
16014 }
16015 16320 }
16016
16017
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16018 {
16019
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerysize
16020 {
16021 return qe_invalid;
16022 }
16023 16320 }
16024
16025
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16026 {
16027
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layeryspeed
16028 {
16029 return qe_invalid;
16030 }
16031 16320 }
16032
16033
2/2
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 16320 times.
19040 for(int32_t k=0; k<6; k++)
16034 {
16035
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerydelay
16036 {
16037 return qe_invalid;
16038 }
16039 16320 }
16040 2720 }
16041
16042
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 690064 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
714960 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>149)))
16043 {
16044
2/2
✓ Branch 0 taken 4156704 times.
✓ Branch 1 taken 692784 times.
4849488 for(int32_t k=0; k<6; k++)
16045 {
16046
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4156704 times.
4156704 if(!p_getc(&(temp_mapscr->layeropacity[k]),f))
16047 {
16048 return qe_invalid;
16049 }
16050 4156704 }
16051 692784 }
16052
16053
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 690064 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
714960 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16054 {
16055
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 690064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
692784 if((Header->zelda_version == 0x192)&&(Header->build>153))
16056 {
16057
1/2
✓ Branch 0 taken 2720 times.
✗ Branch 1 not taken.
2720 if(!p_getc(&padding,f))
16058 {
16059 return qe_invalid;
16060 }
16061 2720 }
16062
16063
1/2
✓ Branch 0 taken 692784 times.
✗ Branch 1 not taken.
692784 if(!p_igetw(&(temp_mapscr->timedwarptics),f))
16064 {
16065 return qe_invalid;
16066 }
16067 692784 }
16068
16069
5/6
✓ Branch 0 taken 692784 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 690064 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
714960 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<24)))
16070 {
16071 22176 extras=15;
16072 22176 }
16073
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 690064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
692784 else if(((Header->zelda_version == 0x192)&&(Header->build<98)))
16074 {
16075 extras=11;
16076 }
16077
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 690064 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
692784 else if((Header->zelda_version == 0x192)&&(Header->build<150))
16078 {
16079 extras=32;
16080 }
16081
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 690064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
692784 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16082 {
16083 extras=64;
16084 }
16085
2/2
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 690064 times.
692784 else if(Header->zelda_version < 0x193)
16086 {
16087 2720 extras=62;
16088 2720 }
16089 else
16090
16091 {
16092 690064 extras=0;
16093 }
16094
16095
2/2
✓ Branch 0 taken 501280 times.
✓ Branch 1 taken 714960 times.
1216240 for(int32_t k=0; k<extras; k++)
16096 {
16097
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 501280 times.
501280 if(!p_getc(&tempbyte,f)) //extra[k]
16098 {
16099 return qe_invalid;
16100 }
16101 501280 }
16102
16103
3/6
✓ Branch 0 taken 336200 times.
✓ Branch 1 taken 378760 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 336200 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
714960 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>2)))
16104 //if (version>3)
16105 {
16106
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 378760 times.
378760 if(!p_getc(&(temp_mapscr->nextmap),f))
16107 {
16108 return qe_invalid;
16109 }
16110
16111
1/2
✓ Branch 0 taken 378760 times.
✗ Branch 1 not taken.
378760 if(!p_getc(&(temp_mapscr->nextscr),f))
16112 {
16113 return qe_invalid;
16114 }
16115 378760 }
16116 else
16117 {
16118 336200 temp_mapscr->nextmap=0;
16119 336200 temp_mapscr->nextscr=0;
16120 }
16121
16122
5/6
✓ Branch 0 taken 692784 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 690064 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
714960 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16123 {
16124 22176 secretcombos=20;
16125 22176 }
16126
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 690064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
692784 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16127 {
16128 secretcombos=256;
16129 }
16130 else
16131 {
16132 692784 secretcombos=128;
16133 }
16134
16135
5/6
✓ Branch 0 taken 692784 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 690064 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
714960 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16136 {
16137
2/2
✓ Branch 0 taken 443520 times.
✓ Branch 1 taken 22176 times.
465696 for(int32_t k=0; k<secretcombos; k++)
16138 {
16139
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443520 times.
443520 if(!p_getc(&tempbyte,f))
16140 {
16141 return qe_invalid;
16142 }
16143
16144
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443520 times.
443520 if(k<128)
16145 {
16146 443520 temp_mapscr->secretcombo[k]=tempbyte;
16147 443520 }
16148 443520 }
16149 22176 }
16150 else
16151 {
16152
2/2
✓ Branch 0 taken 88676352 times.
✓ Branch 1 taken 692784 times.
89369136 for(int32_t k=0; k<128; k++)
16153 {
16154
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88676352 times.
88676352 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f))
16155 {
16156 return qe_invalid;
16157 }
16158
16159 88676352 }
16160 }
16161
16162
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 690064 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
714960 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16163 {
16164
2/2
✓ Branch 0 taken 88676352 times.
✓ Branch 1 taken 692784 times.
89369136 for(int32_t k=0; k<128; k++)
16165 {
16166
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88676352 times.
88676352 if(!p_getc(&(temp_mapscr->secretcset[k]),f))
16167 {
16168 return qe_invalid;
16169 }
16170 88676352 }
16171
16172
2/2
✓ Branch 0 taken 88676352 times.
✓ Branch 1 taken 692784 times.
89369136 for(int32_t k=0; k<128; k++)
16173 {
16174
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88676352 times.
88676352 if(!p_getc(&(temp_mapscr->secretflag[k]),f))
16175 {
16176 return qe_invalid;
16177 }
16178 88676352 }
16179 692784 }
16180
16181
4/6
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 712240 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
714960 if((Header->zelda_version == 0x192)&&(Header->build>97)&&(Header->build<154))
16182 {
16183 if(!p_getc(&padding,f))
16184 {
16185 return qe_invalid;
16186 }
16187 }
16188
16189
2/2
✓ Branch 0 taken 125832960 times.
✓ Branch 1 taken 714960 times.
126547920 for(int32_t k=0; k<176; k++)
16190 {
16191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125832960 times.
125832960 if(!p_igetw(&(temp_mapscr->data[k]),f))
16192 {
16193 return qe_invalid;
16194 }
16195 125832960 }
16196
16197
4/6
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 712240 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
714960 if((Header->zelda_version == 0x192)&&(Header->build>20)&&(Header->build<24))
16198 {
16199 if(!p_getc(&padding,f))
16200 {
16201 return qe_invalid;
16202 }
16203
16204 if(!p_getc(&padding,f))
16205 {
16206 return qe_invalid;
16207 }
16208 }
16209
16210
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 690064 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
714960 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>20)))
16211 {
16212
2/2
✓ Branch 0 taken 121929984 times.
✓ Branch 1 taken 692784 times.
122622768 for(int32_t k=0; k<176; k++)
16213 {
16214
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 121929984 times.
121929984 if(!p_getc(&(temp_mapscr->sflag[k]),f))
16215 {
16216 return qe_invalid;
16217 }
16218
16219
3/4
✓ Branch 0 taken 478720 times.
✓ Branch 1 taken 121451264 times.
✓ Branch 2 taken 478720 times.
✗ Branch 3 not taken.
121929984 if((Header->zelda_version == 0x192)&&(Header->build<24))
16220 {
16221 if(!p_getc(&tempbyte,f))
16222 {
16223 return qe_invalid;
16224 }
16225
16226 if(!p_getc(&tempbyte,f))
16227 {
16228 return qe_invalid;
16229 }
16230
16231 if(!p_getc(&tempbyte,f))
16232 {
16233 return qe_invalid;
16234 }
16235 }
16236 121929984 }
16237 692784 }
16238
16239
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 690064 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
714960 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16240 {
16241
2/2
✓ Branch 0 taken 692784 times.
✓ Branch 1 taken 121929984 times.
122622768 for(int32_t k=0; k<176; k++)
16242 {
16243
16244
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 121929984 times.
121929984 if(!p_getc(&(temp_mapscr->cset[k]),f))
16245 {
16246 return qe_invalid;
16247 }
16248 121929984 }
16249 692784 }
16250
16251
5/6
✓ Branch 0 taken 692784 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 690064 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
714960 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16252 {
16253 22176 temp_mapscr->undercset=(temp_mapscr->undercombo>>8)&7;
16254 22176 temp_mapscr->undercombo=(temp_mapscr->undercombo&0xFF)+(temp_mapscr->old_cpage<<8);
16255 22176 }
16256
16257
5/6
✓ Branch 0 taken 692784 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 690064 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
714960 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16258 {
16259 22176 temp_mapscr->secretcombo[sSBOMB]=temp_mapscr->secretcombo[sBOMB];
16260 22176 temp_mapscr->secretcombo[sRCANDLE]=temp_mapscr->secretcombo[sBCANDLE];
16261 22176 temp_mapscr->secretcombo[sWANDFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16262 22176 temp_mapscr->secretcombo[sDIVINEFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16263 22176 temp_mapscr->secretcombo[sSARROW]=temp_mapscr->secretcombo[sARROW];
16264 22176 temp_mapscr->secretcombo[sGARROW]=temp_mapscr->secretcombo[sARROW];
16265 22176 }
16266
16267
5/6
✓ Branch 0 taken 692784 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 690064 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
714960 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16268 {
16269
2/2
✓ Branch 0 taken 3902976 times.
✓ Branch 1 taken 22176 times.
3925152 for(int32_t k=0; k<176; k++)
16270 {
16271
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3902976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3902976 if((Header->zelda_version == 0x192)&&(Header->build>149))
16272 {
16273 if((Header->zelda_version == 0x192)&&(Header->build!=153))
16274 {
16275 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16276 }
16277 }
16278 else
16279 {
16280
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3902976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3902976 if((Header->zelda_version < 0x192)||
16281 ((Header->zelda_version == 0x192)&&(Header->build<21)))
16282 {
16283 3902976 temp_mapscr->sflag[k]=(temp_mapscr->data[k]>>11);
16284 3902976 }
16285
16286 3902976 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16287 }
16288
16289 3902976 temp_mapscr->data[k]=(temp_mapscr->data[k]&0xFF)+(temp_mapscr->old_cpage<<8);
16290 3902976 }
16291 22176 }
16292
16293 /*if(version>12)
16294 {
16295 if(!p_getc(&(temp_mapscr->scrWidth),f))
16296 {
16297 return qe_invalid;
16298 }
16299 if(!p_getc(&(temp_mapscr->scrHeight),f))
16300 {
16301 return qe_invalid;
16302 }
16303 }*/
16304
16305
2/2
✓ Branch 0 taken 378760 times.
✓ Branch 1 taken 336200 times.
714960 if(version>4)
16306 {
16307
1/2
✓ Branch 0 taken 378760 times.
✗ Branch 1 not taken.
378760 if(!p_igetw(&(temp_mapscr->screen_midi),f))
16308 {
16309 return qe_invalid;
16310 }
16311 378760 }
16312 else
16313 {
16314 336200 temp_mapscr->screen_midi = -1;
16315 }
16316
16317
2/2
✓ Branch 0 taken 378760 times.
✓ Branch 1 taken 336200 times.
714960 if(version>=17)
16318 {
16319
1/2
✓ Branch 0 taken 378760 times.
✗ Branch 1 not taken.
378760 if(!p_getc(&(temp_mapscr->lens_layer),f))
16320 {
16321 return qe_invalid;
16322 }
16323 378760 }
16324 else
16325 {
16326 336200 temp_mapscr->lens_layer = llNORMAL;
16327 }
16328
16329
2/2
✓ Branch 0 taken 336200 times.
✓ Branch 1 taken 378760 times.
714960 if(version>6)
16330 {
16331 dword bits;
16332
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 378760 times.
378760 if(!p_igetl(&bits,f))
16333 {
16334 return qe_invalid;
16335 }
16336
16337 int32_t m;
16338 float tempfloat;
16339 word tempw;
16340 378760 temp_mapscr->ffcCountMarkDirty();
16341
16342
2/2
✓ Branch 0 taken 378760 times.
✓ Branch 1 taken 12120320 times.
12499080 for(m=0; m<32; m++)
16343 {
16344 12120320 ffcdata& tempffc = temp_mapscr->ffcs[m];
16345 12120320 tempffc.clear();
16346
2/2
✓ Branch 0 taken 11991062 times.
✓ Branch 1 taken 129258 times.
12120320 if((bits>>m)&1)
16347 {
16348
1/2
✓ Branch 0 taken 129258 times.
✗ Branch 1 not taken.
129258 if(!p_igetw(&tempw,f))
16349 {
16350 return qe_invalid;
16351 }
16352 129258 tempffc.data = tempw;
16353
16354
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129258 times.
129258 if(!p_getc(&(tempffc.cset),f))
16355 {
16356 return qe_invalid;
16357 }
16358
16359
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129258 times.
129258 if(!p_igetw(&(tempffc.delay),f))
16360 {
16361 return qe_invalid;
16362 }
16363
16364
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129258 times.
129258 if(version < 9)
16365 {
16366 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16367 {
16368 return qe_invalid;
16369 }
16370
16371 tempffc.x=zslongToFix(int32_t(tempfloat*10000));
16372
16373 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16374 {
16375 return qe_invalid;
16376 }
16377
16378 tempffc.y=zslongToFix(int32_t(tempfloat*10000));
16379
16380 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16381 {
16382 return qe_invalid;
16383 }
16384
16385 tempffc.vx=zslongToFix(int32_t(tempfloat*10000));
16386
16387 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16388 {
16389 return qe_invalid;
16390 }
16391
16392 tempffc.vy=zslongToFix(int32_t(tempfloat*10000));
16393
16394 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16395 {
16396 return qe_invalid;
16397 }
16398
16399 tempffc.ax=zslongToFix(int32_t(tempfloat*10000));
16400
16401 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16402 {
16403 return qe_invalid;
16404 }
16405
16406 tempffc.ay=zslongToFix(int32_t(tempfloat*10000));
16407 }
16408 else
16409 {
16410
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129258 times.
129258 if(!p_igetzf(&(tempffc.x),f))
16411 {
16412 return qe_invalid;
16413 }
16414
16415
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129258 times.
129258 if(!p_igetzf(&(tempffc.y),f))
16416 {
16417 return qe_invalid;
16418 }
16419
16420
1/2
✓ Branch 0 taken 129258 times.
✗ Branch 1 not taken.
129258 if(!p_igetzf(&(tempffc.vx),f))
16421 {
16422 return qe_invalid;
16423 }
16424
16425
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129258 times.
129258 if(!p_igetzf(&(tempffc.vy),f))
16426 {
16427 return qe_invalid;
16428 }
16429
16430
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129258 times.
129258 if(!p_igetzf(&(tempffc.ax),f))
16431 {
16432 return qe_invalid;
16433 }
16434
16435
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129258 times.
129258 if(!p_igetzf(&(tempffc.ay),f))
16436 {
16437 return qe_invalid;
16438 }
16439 }
16440
16441
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129258 times.
129258 if(!p_getc(&(tempffc.link),f))
16442 {
16443 return qe_invalid;
16444 }
16445
16446
1/2
✓ Branch 0 taken 129258 times.
✗ Branch 1 not taken.
129258 if(version>7)
16447 {
16448
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129258 times.
129258 if(!p_getc(&tempbyte,f))
16449 {
16450 return qe_invalid;
16451 }
16452
16453 129258 tempffc.hit_width = (tempbyte&0x3F)+1;
16454 129258 tempffc.txsz = (tempbyte>>6)+1;
16455
16456
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129258 times.
129258 if(!p_getc(&tempbyte,f))
16457 {
16458 return qe_invalid;
16459 }
16460
16461 129258 tempffc.hit_height = (tempbyte&0x3F)+1;
16462 129258 tempffc.tysz = (tempbyte>>6)+1;
16463
16464
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129258 times.
129258 if(!p_igetl(&(tempffc.flags),f))
16465 {
16466 return qe_invalid;
16467 }
16468 129258 }
16469 else
16470 {
16471 tempffc.hit_width=16;
16472 tempffc.hit_height=16;
16473 tempffc.txsz=1;
16474 tempffc.tysz=1;
16475 tempffc.flags=0;
16476 }
16477
16478 129258 tempffc.updateSolid();
16479
16480
16481
4/6
✓ Branch 0 taken 129258 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 123254 times.
✓ Branch 3 taken 6004 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 123254 times.
129258 if(Header->zelda_version == 0x211 || (Header->zelda_version == 0x250 && Header->build<20))
16482 {
16483 tempffc.flags|=ffIGNOREHOLDUP;
16484 }
16485
16486
1/2
✓ Branch 0 taken 129258 times.
✗ Branch 1 not taken.
129258 if(version>9)
16487 {
16488
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129258 times.
129258 if(!p_igetw(&(tempffc.script),f))
16489 {
16490 return qe_invalid;
16491 }
16492 129258 }
16493 else
16494 {
16495 tempffc.script=0;
16496 }
16497
16498
1/2
✓ Branch 0 taken 129258 times.
✗ Branch 1 not taken.
129258 if(version>10)
16499 {
16500
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129258 times.
129258 if(!p_igetl(&(tempffc.initd[0]),f))
16501 {
16502 return qe_invalid;
16503 }
16504
16505
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129258 times.
129258 if(!p_igetl(&(tempffc.initd[1]),f))
16506 {
16507 return qe_invalid;
16508 }
16509
16510
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129258 times.
129258 if(!p_igetl(&(tempffc.initd[2]),f))
16511 {
16512 return qe_invalid;
16513 }
16514
16515
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129258 times.
129258 if(!p_igetl(&(tempffc.initd[3]),f))
16516 {
16517 return qe_invalid;
16518 }
16519
16520
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129258 times.
129258 if(!p_igetl(&(tempffc.initd[4]),f))
16521 {
16522 return qe_invalid;
16523 }
16524
16525
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129258 times.
129258 if(!p_igetl(&(tempffc.initd[5]),f))
16526 {
16527 return qe_invalid;
16528 }
16529
16530
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129258 times.
129258 if(!p_igetl(&(tempffc.initd[6]),f))
16531 {
16532 return qe_invalid;
16533 }
16534
16535
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129258 times.
129258 if(!p_igetl(&(tempffc.initd[7]),f))
16536 {
16537 return qe_invalid;
16538 }
16539
16540
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129258 times.
129258 if(!p_getc(&(tempbyte),f))
16541 {
16542 return qe_invalid;
16543 }
16544
16545 129258 tempffc.inita[0]=tempbyte*10000;
16546
16547
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129258 times.
129258 if(!p_getc(&(tempbyte),f))
16548 {
16549 return qe_invalid;
16550 }
16551
16552 129258 tempffc.inita[1]=tempbyte*10000;
16553 129258 }
16554 else
16555 {
16556 tempffc.inita[0] = 10000;
16557 tempffc.inita[1] = 10000;
16558 }
16559
16560
1/2
✓ Branch 0 taken 129258 times.
✗ Branch 1 not taken.
129258 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
16561 {
16562 tempffc.script = 0;
16563 for(int q = 0; q < 8; ++q)
16564 tempffc.initd[q] = 0;
16565 }
16566
1/2
✓ Branch 0 taken 129258 times.
✗ Branch 1 not taken.
129258 if(version <= 11)
16567 {
16568 fixffcs=true;
16569 }
16570 129258 }
16571 12120320 }
16572
2/2
✓ Branch 0 taken 36360960 times.
✓ Branch 1 taken 378760 times.
36739720 for(m = 32; m < MAXFFCS; ++m)
16573 {
16574 36360960 temp_mapscr->ffcs[m].clear();
16575 36360960 }
16576 378760 }
16577
16578 //add in the new whistle flags
16579
2/2
✓ Branch 0 taken 378760 times.
✓ Branch 1 taken 336200 times.
714960 if(version<13)
16580 {
16581
2/2
✓ Branch 0 taken 95 times.
✓ Branch 1 taken 336105 times.
336200 if(temp_mapscr->flags & fWHISTLE)
16582 {
16583 95 temp_mapscr->flags7 |= (fWHISTLEPAL | fWHISTLEWATER);
16584 95 }
16585 336200 }
16586
16587 //2.55 starts here
16588
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 680552 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
714960 if ( version >= 19 && Header->zelda_version > 0x253 )
16589 {
16590
2/2
✓ Branch 0 taken 344080 times.
✓ Branch 1 taken 34408 times.
378488 for ( int32_t q = 0; q < 10; q++ )
16591 {
16592
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 344080 times.
344080 if(!p_igetl(&(temp_mapscr->npcstrings[q]),f))
16593 {
16594 return qe_invalid;
16595 }
16596 344080 }
16597
2/2
✓ Branch 0 taken 344080 times.
✓ Branch 1 taken 34408 times.
378488 for ( int32_t q = 0; q < 10; q++ )
16598 {
16599
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 344080 times.
344080 if(!p_igetw(&(temp_mapscr->new_items[q]),f))
16600 {
16601 return qe_invalid;
16602 }
16603 344080 }
16604
2/2
✓ Branch 0 taken 344080 times.
✓ Branch 1 taken 34408 times.
378488 for ( int32_t q = 0; q < 10; q++ )
16605 {
16606
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 344080 times.
344080 if(!p_igetw(&(temp_mapscr->new_item_x[q]),f))
16607 {
16608 return qe_invalid;
16609 }
16610 344080 }
16611
2/2
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 344080 times.
378488 for ( int32_t q = 0; q < 10; q++ )
16612 {
16613
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 344080 times.
344080 if(!p_igetw(&(temp_mapscr->new_item_y[q]),f))
16614 {
16615 return qe_invalid;
16616 }
16617 344080 }
16618 34408 }
16619
3/4
✓ Branch 0 taken 680552 times.
✓ Branch 1 taken 34408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 680552 times.
714960 if ( version < 19 && Header->zelda_version > 0x253 )
16620 {
16621 for ( int32_t q = 0; q < 10; q++ )
16622 {
16623 temp_mapscr->npcstrings[q] = 0;
16624 temp_mapscr->new_items[q] = 0;
16625 temp_mapscr->new_item_x[q] = 0;
16626 temp_mapscr->new_item_y[q] = 0;
16627 }
16628 }
16629
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 680552 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
714960 if ( version >= 20 && Header->zelda_version > 0x253 )
16630 {
16631
1/2
✓ Branch 0 taken 34408 times.
✗ Branch 1 not taken.
34408 if(!p_igetw(&(temp_mapscr->script),f))
16632 {
16633 return qe_invalid;
16634 }
16635
2/2
✓ Branch 0 taken 275264 times.
✓ Branch 1 taken 34408 times.
309672 for ( int32_t q = 0; q < 8; q++)
16636 {
16637
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275264 times.
275264 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f))
16638 {
16639 return qe_invalid;
16640 }
16641 275264 }
16642 34408 }
16643
2/2
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 680552 times.
714960 if ( version < 20 )
16644 {
16645 680552 temp_mapscr->script = 0;
16646
2/2
✓ Branch 0 taken 5444416 times.
✓ Branch 1 taken 680552 times.
6124968 for ( int32_t q = 0; q < 8; q++) temp_mapscr->screeninitd[q] = 0;
16647 680552 }
16648
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 680552 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
714960 if ( version >= 21 && Header->zelda_version > 0x253 )
16649 {
16650
1/2
✓ Branch 0 taken 34408 times.
✗ Branch 1 not taken.
34408 if(!p_getc(&(temp_mapscr->preloadscript),f))
16651 {
16652 return qe_invalid;
16653 }
16654 34408 }
16655
2/2
✓ Branch 0 taken 680552 times.
✓ Branch 1 taken 34408 times.
714960 if ( version < 21 )
16656 {
16657 680552 temp_mapscr->preloadscript = 0;
16658 680552 }
16659 //all builds with version > 20 need this. -Z
16660
16661
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 680552 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
714960 if ( version >= 22 && Header->zelda_version > 0x253 ) //26th June, 2019; Layer Visibility
16662 {
16663
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34408 times.
34408 if(!p_getc(&(temp_mapscr->hidelayers ),f))
16664 {
16665 return qe_invalid;
16666 }
16667
1/2
✓ Branch 0 taken 34408 times.
✗ Branch 1 not taken.
34408 if(!p_getc(&(temp_mapscr->hidescriptlayers ),f))
16668 {
16669 return qe_invalid;
16670 }
16671 34408 }
16672
2/2
✓ Branch 0 taken 680552 times.
✓ Branch 1 taken 34408 times.
714960 if ( version < 22 )
16673 {
16674 680552 temp_mapscr->hidelayers = 0;
16675 680552 temp_mapscr->hidescriptlayers = 0;
16676 680552 }
16677
16678 //Dodongos in 2.10 used the boss roar, not the dodongo sound. -Z
16679 //May be any version before 2.11. -Z
16680 /* --not the roar, the HIT SFX
16681 if ( Header->zelda_version <= 0x210 )
16682 {
16683 if ( temp_mapscr->bosssfx == WAV_DODONGO )
16684 {
16685 temp_mapscr->bosssfx = WAV_ROAR;
16686 }
16687 }
16688 */
16689
2/2
✓ Branch 0 taken 2859840 times.
✓ Branch 1 taken 714960 times.
3574800 for(int32_t k=0; k<4; k++)
16690 {
16691
1/2
✓ Branch 0 taken 2859840 times.
✗ Branch 1 not taken.
2859840 if(temp_mapscr->door[k] == dNONE)
16692 temp_mapscr->door[k] = dWALL;
16693 2859840 }
16694
16695 714960 return 0;
16696 714960 }
16697 859936 int32_t readmapscreen(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, word version, int scrind)
16698 {
16699
2/2
✓ Branch 0 taken 714960 times.
✓ Branch 1 taken 144976 times.
859936 if(version < 23)
16700 {
16701 714960 auto ret = readmapscreen_old(f,Header,temp_mapscr,version);
16702
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 714960 times.
714960 if(ret) return ret;
16703 714960 }
16704 else
16705 {
16706
1/2
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
144976 if(!p_getc(&(temp_mapscr->valid),f))
16707 return qe_invalid;
16708
2/2
✓ Branch 0 taken 112469 times.
✓ Branch 1 taken 32507 times.
144976 if(!(temp_mapscr->valid & mVALID))
16709 {
16710 112469 int map = scrind/MAPSCRS;
16711 112469 int scr = scrind%MAPSCRS;
16712
4/6
✓ Branch 0 taken 105107 times.
✓ Branch 1 taken 7362 times.
✓ Branch 2 taken 105107 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 105107 times.
✗ Branch 5 not taken.
112469 if(version > 25 && scrind > -1 && (map*6+5) < map_autolayers.size())
16713 {
16714 //Empty screen, apply autolayers
16715
2/2
✓ Branch 0 taken 6399 times.
✓ Branch 1 taken 105107 times.
111506 for(int q = 0; q < 6; ++q)
16716 {
16717 6399 auto layermap = map_autolayers[map*6+q];
16718 6399 temp_mapscr->layermap[q] = layermap;
16719 6399 if(layermap)
16720 6399 temp_mapscr->layerscreen[q] = scr;
16721 6399 }
16722 105107 }
16723 112469 return 0;
16724 }
16725 uint32_t scr_has_flags;
16726
1/2
✓ Branch 0 taken 32507 times.
✗ Branch 1 not taken.
32507 if(!p_igetl(&scr_has_flags,f))
16727 return qe_invalid;
16728
16729
2/2
✓ Branch 0 taken 10470 times.
✓ Branch 1 taken 22037 times.
32507 if(scr_has_flags & SCRHAS_ROOMDATA)
16730 {
16731
1/2
✓ Branch 0 taken 22037 times.
✗ Branch 1 not taken.
22037 if(!p_getc(&(temp_mapscr->guy),f))
16732 return qe_invalid;
16733
2/2
✓ Branch 0 taken 21917 times.
✓ Branch 1 taken 120 times.
22037 if(version > 26)
16734 {
16735
1/2
✓ Branch 0 taken 21917 times.
✗ Branch 1 not taken.
21917 if(!p_igetl(&(temp_mapscr->guytile),f))
16736 return qe_invalid;
16737
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21917 times.
21917 if(!p_getc(&(temp_mapscr->guycs),f))
16738 return qe_invalid;
16739
1/2
✓ Branch 0 taken 21917 times.
✗ Branch 1 not taken.
21917 if(!p_igetw(&(temp_mapscr->roomflags),f))
16740 return qe_invalid;
16741 21917 }
16742 else
16743 {
16744 120 temp_mapscr->guytile = -1; //signal to use default guy values
16745
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 SETFLAG(temp_mapscr->roomflags,RFL_ALWAYS_GUY,temp_mapscr->guy==gFAIRY);
16746
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
120 SETFLAG(temp_mapscr->roomflags,RFL_GUYFIRES,temp_mapscr->guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES));
16747 }
16748
1/2
✓ Branch 0 taken 22037 times.
✗ Branch 1 not taken.
22037 if(!p_igetw(&(temp_mapscr->str),f))
16749 return qe_invalid;
16750
1/2
✓ Branch 0 taken 22037 times.
✗ Branch 1 not taken.
22037 if(!p_getc(&(temp_mapscr->room),f))
16751 return qe_invalid;
16752
1/2
✓ Branch 0 taken 22037 times.
✗ Branch 1 not taken.
22037 if(!p_igetw(&(temp_mapscr->catchall),f))
16753 return qe_invalid;
16754 22037 }
16755
2/2
✓ Branch 0 taken 31450 times.
✓ Branch 1 taken 1057 times.
32507 if(scr_has_flags & SCRHAS_ITEM)
16756 {
16757
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1057 times.
1057 if(!p_getc(&(temp_mapscr->item),f))
16758 return qe_invalid;
16759
1/2
✓ Branch 0 taken 1057 times.
✗ Branch 1 not taken.
1057 if(!p_getc(&(temp_mapscr->hasitem),f))
16760 return qe_invalid;
16761
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1057 times.
1057 if(!p_getc(&(temp_mapscr->itemx),f))
16762 return qe_invalid;
16763
1/2
✓ Branch 0 taken 1057 times.
✗ Branch 1 not taken.
1057 if(!p_getc(&(temp_mapscr->itemy),f))
16764 return qe_invalid;
16765 1057 }
16766
2/2
✓ Branch 0 taken 27833 times.
✓ Branch 1 taken 4674 times.
32507 if(scr_has_flags & (SCRHAS_SWARP|SCRHAS_TWARP))
16767 {
16768
1/2
✓ Branch 0 taken 4674 times.
✗ Branch 1 not taken.
4674 if(!p_igetw(&temp_mapscr->warpreturnc,f))
16769 return qe_invalid;
16770 4674 }
16771
2/2
✓ Branch 0 taken 31067 times.
✓ Branch 1 taken 1440 times.
32507 if(scr_has_flags & SCRHAS_TWARP)
16772 {
16773
2/2
✓ Branch 0 taken 5760 times.
✓ Branch 1 taken 1440 times.
7200 for(int32_t i=0; i<4; i++)
16774 {
16775
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5760 times.
5760 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f))
16776 return qe_invalid;
16777 5760 }
16778
2/2
✓ Branch 0 taken 5760 times.
✓ Branch 1 taken 1440 times.
7200 for(int32_t i=0; i<4; i++)
16779 {
16780
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5760 times.
5760 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f))
16781 return qe_invalid;
16782 5760 }
16783
2/2
✓ Branch 0 taken 5760 times.
✓ Branch 1 taken 1440 times.
7200 for(int32_t i=0; i<4; i++)
16784 {
16785
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5760 times.
5760 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f))
16786 return qe_invalid;
16787 5760 }
16788
1/2
✓ Branch 0 taken 1440 times.
✗ Branch 1 not taken.
1440 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f))
16789 return qe_invalid;
16790 1440 }
16791
2/2
✓ Branch 0 taken 28965 times.
✓ Branch 1 taken 3542 times.
32507 if(scr_has_flags & SCRHAS_SWARP)
16792 {
16793
2/2
✓ Branch 0 taken 14168 times.
✓ Branch 1 taken 3542 times.
17710 for(int32_t i=0; i<4; i++)
16794 {
16795
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14168 times.
14168 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f))
16796 return qe_invalid;
16797 14168 }
16798
2/2
✓ Branch 0 taken 14168 times.
✓ Branch 1 taken 3542 times.
17710 for(int32_t i=0; i<4; i++)
16799 {
16800
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14168 times.
14168 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f))
16801 return qe_invalid;
16802 14168 }
16803
2/2
✓ Branch 0 taken 14168 times.
✓ Branch 1 taken 3542 times.
17710 for(int32_t i=0; i<4; i++)
16804 {
16805
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14168 times.
14168 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f))
16806 return qe_invalid;
16807 14168 }
16808
1/2
✓ Branch 0 taken 3542 times.
✗ Branch 1 not taken.
3542 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f))
16809 return qe_invalid;
16810
1/2
✓ Branch 0 taken 3542 times.
✗ Branch 1 not taken.
3542 if(!p_getc(&(temp_mapscr->sidewarpindex),f))
16811 return qe_invalid;
16812 3542 }
16813
2/2
✓ Branch 0 taken 28829 times.
✓ Branch 1 taken 3678 times.
32507 if(scr_has_flags & SCRHAS_WARPRET)
16814 {
16815
2/2
✓ Branch 0 taken 14712 times.
✓ Branch 1 taken 3678 times.
18390 for(int32_t i=0; i<4; i++)
16816 {
16817
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14712 times.
14712 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f))
16818 return qe_invalid;
16819 14712 }
16820
2/2
✓ Branch 0 taken 14712 times.
✓ Branch 1 taken 3678 times.
18390 for(int32_t i=0; i<4; i++)
16821 {
16822
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14712 times.
14712 if(!p_getc(&(temp_mapscr->warpreturny[i]),f))
16823 return qe_invalid;
16824 14712 }
16825
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3678 times.
3678 if(!p_getc(&(temp_mapscr->warparrivalx),f))
16826 return qe_invalid;
16827
1/2
✓ Branch 0 taken 3678 times.
✗ Branch 1 not taken.
3678 if(!p_getc(&(temp_mapscr->warparrivaly),f))
16828 return qe_invalid;
16829 3678 }
16830
2/2
✓ Branch 0 taken 25753 times.
✓ Branch 1 taken 6754 times.
32507 if(scr_has_flags & SCRHAS_LAYERS)
16831 {
16832
2/2
✓ Branch 0 taken 40524 times.
✓ Branch 1 taken 6754 times.
47278 for(int32_t k=0; k<6; k++)
16833 {
16834
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40524 times.
40524 if(!p_getc(&(temp_mapscr->layermap[k]),f))
16835 return qe_invalid;
16836 40524 }
16837
2/2
✓ Branch 0 taken 40524 times.
✓ Branch 1 taken 6754 times.
47278 for(int32_t k=0; k<6; k++)
16838 {
16839
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40524 times.
40524 if(!p_getc(&(temp_mapscr->layerscreen[k]),f))
16840 return qe_invalid;
16841 40524 }
16842
2/2
✓ Branch 0 taken 40524 times.
✓ Branch 1 taken 6754 times.
47278 for(int32_t k=0; k<6; k++)
16843 {
16844
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40524 times.
40524 if(!p_getc(&(temp_mapscr->layeropacity[k]),f))
16845 return qe_invalid;
16846 40524 }
16847
1/2
✓ Branch 0 taken 6754 times.
✗ Branch 1 not taken.
6754 if(!p_getc(&(temp_mapscr->hidelayers),f))
16848 return qe_invalid;
16849
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6754 times.
6754 if(!p_getc(&(temp_mapscr->hidescriptlayers),f))
16850 return qe_invalid;
16851 6754 }
16852
2/2
✓ Branch 0 taken 32505 times.
✓ Branch 1 taken 2 times.
32507 if(scr_has_flags & SCRHAS_MAZE)
16853 {
16854
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 for(int32_t k=0; k<4; k++)
16855 {
16856
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!p_getc(&(temp_mapscr->path[k]),f))
16857 return qe_invalid;
16858 8 }
16859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(!p_getc(&(temp_mapscr->exitdir),f))
16860 return qe_invalid;
16861 2 }
16862
2/2
✓ Branch 0 taken 14470 times.
✓ Branch 1 taken 18037 times.
32507 if(scr_has_flags & SCRHAS_D_S_U)
16863 {
16864
1/2
✓ Branch 0 taken 14470 times.
✗ Branch 1 not taken.
14470 if(!p_igetw(&(temp_mapscr->door_combo_set),f))
16865 return qe_invalid;
16866
2/2
✓ Branch 0 taken 57880 times.
✓ Branch 1 taken 14470 times.
72350 for(int32_t k=0; k<4; k++)
16867 {
16868
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57880 times.
57880 if(!p_getc(&(temp_mapscr->door[k]),f))
16869 return qe_invalid;
16870
3/4
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 57504 times.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
57880 if(version < 29 && temp_mapscr->door[k] == dNONE)
16871 temp_mapscr->door[k] = dWALL;
16872 57880 }
16873
16874
1/2
✓ Branch 0 taken 14470 times.
✗ Branch 1 not taken.
14470 if(!p_getc(&(temp_mapscr->stairx),f))
16875 return qe_invalid;
16876
16877
1/2
✓ Branch 0 taken 14470 times.
✗ Branch 1 not taken.
14470 if(!p_getc(&(temp_mapscr->stairy),f))
16878 return qe_invalid;
16879
1/2
✓ Branch 0 taken 14470 times.
✗ Branch 1 not taken.
14470 if(!p_igetw(&(temp_mapscr->undercombo),f))
16880 return qe_invalid;
16881
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14470 times.
14470 if(!p_getc(&(temp_mapscr->undercset),f))
16882 return qe_invalid;
16883 14470 }
16884
2/2
✓ Branch 0 taken 7541 times.
✓ Branch 1 taken 10496 times.
18037 else if(version < 29)
16885 {
16886
2/2
✓ Branch 0 taken 41984 times.
✓ Branch 1 taken 10496 times.
52480 for(int k = 0; k < 4; ++k)
16887 41984 temp_mapscr->door[k] = dWALL;
16888 10496 }
16889
2/2
✓ Branch 0 taken 28592 times.
✓ Branch 1 taken 3915 times.
32507 if(scr_has_flags & SCRHAS_FLAGS)
16890 {
16891
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3915 times.
3915 if(!p_getc(&(temp_mapscr->flags),f))
16892 return qe_invalid;
16893
1/2
✓ Branch 0 taken 3915 times.
✗ Branch 1 not taken.
3915 if(!p_getc(&(temp_mapscr->flags2),f))
16894 return qe_invalid;
16895
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3915 times.
3915 if(!p_getc(&(temp_mapscr->flags3),f))
16896 return qe_invalid;
16897
1/2
✓ Branch 0 taken 3915 times.
✗ Branch 1 not taken.
3915 if(!p_getc(&(temp_mapscr->flags4),f))
16898 return qe_invalid;
16899
1/2
✓ Branch 0 taken 3915 times.
✗ Branch 1 not taken.
3915 if(!p_getc(&(temp_mapscr->flags5),f))
16900 return qe_invalid;
16901
1/2
✓ Branch 0 taken 3915 times.
✗ Branch 1 not taken.
3915 if(!p_getc(&(temp_mapscr->flags6),f))
16902 return qe_invalid;
16903
1/2
✓ Branch 0 taken 3915 times.
✗ Branch 1 not taken.
3915 if(!p_getc(&(temp_mapscr->flags7),f))
16904 return qe_invalid;
16905
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3915 times.
3915 if(!p_getc(&(temp_mapscr->flags8),f))
16906 return qe_invalid;
16907
1/2
✓ Branch 0 taken 3915 times.
✗ Branch 1 not taken.
3915 if(!p_getc(&(temp_mapscr->flags9),f))
16908 return qe_invalid;
16909
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3915 times.
3915 if(!p_getc(&(temp_mapscr->flags10),f))
16910 return qe_invalid;
16911
1/2
✓ Branch 0 taken 3915 times.
✗ Branch 1 not taken.
3915 if(!p_getc(&(temp_mapscr->enemyflags),f))
16912 return qe_invalid;
16913 3915 }
16914
2/2
✓ Branch 0 taken 29650 times.
✓ Branch 1 taken 2857 times.
32507 if(scr_has_flags & SCRHAS_ENEMY)
16915 {
16916
2/2
✓ Branch 0 taken 28570 times.
✓ Branch 1 taken 2857 times.
31427 for(int32_t k=0; k<10; k++)
16917 {
16918
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28570 times.
28570 if(!p_igetw(&(temp_mapscr->enemy[k]),f))
16919 return qe_invalid;
16920
1/2
✓ Branch 0 taken 28570 times.
✗ Branch 1 not taken.
28570 if (unsigned(temp_mapscr->enemy[k]) > MAXGUYS)
16921 temp_mapscr->enemy[k] = 0;
16922 28570 }
16923
1/2
✓ Branch 0 taken 2857 times.
✗ Branch 1 not taken.
2857 if(!p_getc(&(temp_mapscr->pattern),f))
16924 return qe_invalid;
16925 2857 }
16926
2/2
✓ Branch 0 taken 32322 times.
✓ Branch 1 taken 185 times.
32507 if(scr_has_flags & SCRHAS_CARRY)
16927 {
16928
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 185 times.
185 if(!p_igetw(&(temp_mapscr->noreset),f))
16929 return qe_invalid;
16930
1/2
✓ Branch 0 taken 185 times.
✗ Branch 1 not taken.
185 if(!p_igetw(&(temp_mapscr->nocarry),f))
16931 return qe_invalid;
16932
1/2
✓ Branch 0 taken 185 times.
✗ Branch 1 not taken.
185 if(!p_getc(&(temp_mapscr->nextmap),f))
16933 return qe_invalid;
16934
1/2
✓ Branch 0 taken 185 times.
✗ Branch 1 not taken.
185 if(!p_getc(&(temp_mapscr->nextscr),f))
16935 return qe_invalid;
16936 185 }
16937
2/2
✓ Branch 0 taken 32107 times.
✓ Branch 1 taken 400 times.
32507 if(scr_has_flags & SCRHAS_SCRIPT)
16938 {
16939
1/2
✓ Branch 0 taken 400 times.
✗ Branch 1 not taken.
400 if(!p_igetw(&(temp_mapscr->script),f))
16940 return qe_invalid;
16941
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 400 times.
400 if(!p_getc(&(temp_mapscr->preloadscript),f))
16942 return qe_invalid;
16943
2/2
✓ Branch 0 taken 3200 times.
✓ Branch 1 taken 400 times.
3600 for ( int32_t q = 0; q < 8; q++ )
16944 {
16945
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3200 times.
3200 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f))
16946 return qe_invalid;
16947 3200 }
16948 400 }
16949
1/2
✓ Branch 0 taken 32507 times.
✗ Branch 1 not taken.
32507 if(scr_has_flags & SCRHAS_UNUSED)
16950 {
16951 for ( int32_t q = 0; q < 10; q++ )
16952 {
16953 if(!p_igetl(&(temp_mapscr->npcstrings[q]),f))
16954 return qe_invalid;
16955 }
16956 for ( int32_t q = 0; q < 10; q++ )
16957 {
16958 if(!p_igetw(&(temp_mapscr->new_items[q]),f))
16959 return qe_invalid;
16960 }
16961 for ( int32_t q = 0; q < 10; q++ )
16962 {
16963 if(!p_igetw(&(temp_mapscr->new_item_x[q]),f))
16964 return qe_invalid;
16965 }
16966 for ( int32_t q = 0; q < 10; q++ )
16967 {
16968 if(!p_igetw(&(temp_mapscr->new_item_y[q]),f))
16969 return qe_invalid;
16970 }
16971 }
16972
2/2
✓ Branch 0 taken 28827 times.
✓ Branch 1 taken 3680 times.
32507 if(scr_has_flags & SCRHAS_SECRETS)
16973 {
16974
2/2
✓ Branch 0 taken 471040 times.
✓ Branch 1 taken 3680 times.
474720 for(int32_t k=0; k<128; k++)
16975 {
16976
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 471040 times.
471040 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f))
16977 return qe_invalid;
16978 471040 }
16979
2/2
✓ Branch 0 taken 471040 times.
✓ Branch 1 taken 3680 times.
474720 for(int32_t k=0; k<128; k++)
16980 {
16981
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 471040 times.
471040 if(!p_getc(&(temp_mapscr->secretcset[k]),f))
16982 return qe_invalid;
16983 471040 }
16984
2/2
✓ Branch 0 taken 471040 times.
✓ Branch 1 taken 3680 times.
474720 for(int32_t k=0; k<128; k++)
16985 {
16986
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 471040 times.
471040 if(!p_getc(&(temp_mapscr->secretflag[k]),f))
16987 return qe_invalid;
16988 471040 }
16989 3680 }
16990
2/2
✓ Branch 0 taken 9875 times.
✓ Branch 1 taken 22632 times.
32507 if(scr_has_flags & SCRHAS_COMBOFLAG)
16991 {
16992
2/2
✓ Branch 0 taken 3983232 times.
✓ Branch 1 taken 22632 times.
4005864 for(int32_t k=0; k<176; ++k)
16993 {
16994
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3983232 times.
3983232 if(!p_igetw(&(temp_mapscr->data[k]),f))
16995 return qe_invalid;
16996 3983232 }
16997
2/2
✓ Branch 0 taken 3983232 times.
✓ Branch 1 taken 22632 times.
4005864 for(int32_t k=0; k<176; ++k)
16998 {
16999
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3983232 times.
3983232 if(!p_getc(&(temp_mapscr->sflag[k]),f))
17000 return qe_invalid;
17001 3983232 }
17002
2/2
✓ Branch 0 taken 3983232 times.
✓ Branch 1 taken 22632 times.
4005864 for(int32_t k=0; k<176; ++k)
17003 {
17004
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3983232 times.
3983232 if(!p_getc(&(temp_mapscr->cset[k]),f))
17005 return qe_invalid;
17006 3983232 }
17007 22632 }
17008
1/2
✓ Branch 0 taken 32507 times.
✗ Branch 1 not taken.
32507 if(scr_has_flags & SCRHAS_MISC)
17009 {
17010
1/2
✓ Branch 0 taken 32507 times.
✗ Branch 1 not taken.
32507 if(!p_igetw(&(temp_mapscr->color),f))
17011 return qe_invalid;
17012
1/2
✓ Branch 0 taken 32507 times.
✗ Branch 1 not taken.
32507 if(!p_getc(&(temp_mapscr->csensitive),f))
17013 return qe_invalid;
17014
1/2
✓ Branch 0 taken 32507 times.
✗ Branch 1 not taken.
32507 if(!p_getc(&(temp_mapscr->oceansfx),f))
17015 return qe_invalid;
17016
1/2
✓ Branch 0 taken 32507 times.
✗ Branch 1 not taken.
32507 if(!p_getc(&(temp_mapscr->bosssfx),f))
17017 return qe_invalid;
17018
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32507 times.
32507 if(!p_getc(&(temp_mapscr->secretsfx),f))
17019 return qe_invalid;
17020
1/2
✓ Branch 0 taken 32507 times.
✗ Branch 1 not taken.
32507 if(!p_getc(&(temp_mapscr->holdupsfx),f))
17021 return qe_invalid;
17022
1/2
✓ Branch 0 taken 32507 times.
✗ Branch 1 not taken.
32507 if(!p_igetw(&(temp_mapscr->timedwarptics),f))
17023 return qe_invalid;
17024
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32507 times.
32507 if(!p_igetw(&(temp_mapscr->screen_midi),f))
17025 return qe_invalid;
17026
1/2
✓ Branch 0 taken 32507 times.
✗ Branch 1 not taken.
32507 if(!p_getc(&(temp_mapscr->lens_layer),f))
17027 return qe_invalid;
17028
2/2
✓ Branch 0 taken 10590 times.
✓ Branch 1 taken 21917 times.
32507 if(version > 27)
17029 {
17030
1/2
✓ Branch 0 taken 21917 times.
✗ Branch 1 not taken.
21917 if(!p_getc(&(temp_mapscr->lens_show),f))
17031 return qe_invalid;
17032
1/2
✓ Branch 0 taken 21917 times.
✗ Branch 1 not taken.
21917 if(!p_getc(&(temp_mapscr->lens_hide),f))
17033 return qe_invalid;
17034 21917 }
17035 32507 }
17036 else
17037 {
17038 temp_mapscr->screen_midi = -1;
17039 temp_mapscr->csensitive = 1;
17040 }
17041 //FFC
17042 32507 bool old_ff = version < 25;
17043 32507 dword bits = 0;
17044 32507 word numffc = 32;
17045
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32507 times.
32507 if(old_ff)
17046 {
17047 if(!p_igetl(&bits,f))
17048 return qe_invalid;
17049 }
17050 else
17051 {
17052
1/2
✓ Branch 0 taken 32507 times.
✗ Branch 1 not taken.
32507 if(!p_igetw(&numffc,f))
17053 return qe_invalid;
17054 }
17055 byte tempbyte;
17056 word tempw;
17057
4/6
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 32235 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 272 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 272 times.
32507 static ffcdata nil_ffc;
17058 32507 temp_mapscr->ffcCountMarkDirty();
17059
2/2
✓ Branch 0 taken 59000 times.
✓ Branch 1 taken 32507 times.
91507 for(word m = 0; m < numffc; ++m)
17060 {
17061
1/2
✓ Branch 0 taken 59000 times.
✗ Branch 1 not taken.
59000 ffcdata& tempffc = (m < MAXFFCS)
17062 59000 ? temp_mapscr->ffcs[m]
17063 : nil_ffc; //sanity
17064 59000 tempffc.clear();
17065
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 59000 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
59000 if(old_ff && !(bits & (1<<m))) continue;
17066
17067
1/2
✓ Branch 0 taken 59000 times.
✗ Branch 1 not taken.
59000 if(!p_igetw(&tempw,f))
17068 return qe_invalid;
17069
3/4
✓ Branch 0 taken 59000 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10362 times.
✓ Branch 3 taken 48638 times.
59000 if(!old_ff && !tempw) //empty ffc, nothing more to load
17070 48638 continue;
17071 10362 tempffc.data = tempw;
17072
17073
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10362 times.
10362 if(!p_getc(&(tempffc.cset),f))
17074 return qe_invalid;
17075
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10362 times.
10362 if(!p_igetw(&(tempffc.delay),f))
17076 return qe_invalid;
17077
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10362 times.
10362 if(!p_igetzf(&(tempffc.x),f))
17078 return qe_invalid;
17079
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10362 times.
10362 if(!p_igetzf(&(tempffc.y),f))
17080 return qe_invalid;
17081
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10362 times.
10362 if(!p_igetzf(&(tempffc.vx),f))
17082 return qe_invalid;
17083
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10362 times.
10362 if(!p_igetzf(&(tempffc.vy),f))
17084 return qe_invalid;
17085
1/2
✓ Branch 0 taken 10362 times.
✗ Branch 1 not taken.
10362 if(!p_igetzf(&(tempffc.ax),f))
17086 return qe_invalid;
17087
1/2
✓ Branch 0 taken 10362 times.
✗ Branch 1 not taken.
10362 if(!p_igetzf(&(tempffc.ay),f))
17088 return qe_invalid;
17089
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10362 times.
10362 if(!p_getc(&(tempffc.link),f))
17090 return qe_invalid;
17091
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10362 times.
10362 if(version < 24)
17092 {
17093 if(!p_getc(&tempbyte,f))
17094 return qe_invalid;
17095 tempffc.hit_width = (tempbyte&0x3F)+1;
17096 tempffc.txsz = (tempbyte>>6)+1;
17097 if(!p_getc(&tempbyte,f))
17098 return qe_invalid;
17099 tempffc.hit_height = (tempbyte&0x3F)+1;
17100 tempffc.tysz = (tempbyte>>6)+1;
17101 }
17102 else
17103 {
17104
1/2
✓ Branch 0 taken 10362 times.
✗ Branch 1 not taken.
10362 if(!p_igetl(&(tempffc.hit_width),f))
17105 return qe_invalid;
17106
1/2
✓ Branch 0 taken 10362 times.
✗ Branch 1 not taken.
10362 if(!p_igetl(&(tempffc.hit_height),f))
17107 return qe_invalid;
17108
1/2
✓ Branch 0 taken 10362 times.
✗ Branch 1 not taken.
10362 if(!p_getc(&(tempffc.txsz),f))
17109 return qe_invalid;
17110
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10362 times.
10362 if(!p_getc(&(tempffc.tysz),f))
17111 return qe_invalid;
17112 }
17113
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10362 times.
10362 if(!p_igetl(&(tempffc.flags),f))
17114 return qe_invalid;
17115 10362 tempffc.updateSolid();
17116
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10362 times.
10362 if(!p_igetw(&(tempffc.script),f))
17117 return qe_invalid;
17118
2/2
✓ Branch 0 taken 82896 times.
✓ Branch 1 taken 10362 times.
93258 for(auto q = 0; q < 8; ++q)
17119 {
17120
1/2
✓ Branch 0 taken 82896 times.
✗ Branch 1 not taken.
82896 if(!p_igetl(&(tempffc.initd[q]),f))
17121 return qe_invalid;
17122 82896 }
17123
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10362 times.
10362 if(!p_getc(&(tempbyte),f))
17124 return qe_invalid;
17125 10362 tempffc.inita[0]=tempbyte*10000;
17126
17127
1/2
✓ Branch 0 taken 10362 times.
✗ Branch 1 not taken.
10362 if(!p_getc(&(tempbyte),f))
17128 return qe_invalid;
17129 10362 tempffc.inita[1]=tempbyte*10000;
17130
17131
1/2
✓ Branch 0 taken 10362 times.
✗ Branch 1 not taken.
10362 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
17132 {
17133 tempffc.script = 0;
17134 for(int q = 0; q < 8; ++q)
17135 tempffc.initd[q] = 0;
17136 }
17137 10362 }
17138
2/2
✓ Branch 0 taken 4101896 times.
✓ Branch 1 taken 32507 times.
4134403 for(word m = numffc; m < MAXFFCS; ++m)
17139 {
17140 4101896 temp_mapscr->ffcs[m].clear();
17141 4101896 }
17142 //END FFC
17143
2/2
✓ Branch 0 taken 24021 times.
✓ Branch 1 taken 8486 times.
32507 if(version > 29)
17144
1/2
✓ Branch 0 taken 8486 times.
✗ Branch 1 not taken.
8486 if(!p_getlstr(&temp_mapscr->usr_notes, f))
17145 return qe_invalid;
17146 }
17147 747467 return 0;
17148 859936 }
17149
17150
17151 589 int32_t readmaps(PACKFILE *f, zquestheader *Header)
17152 {
17153
2/2
✓ Branch 0 taken 565 times.
✓ Branch 1 taken 24 times.
589 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_maps);
17154 589 int32_t scr=0;
17155
17156 589 word version=0;
17157 dword dummy;
17158 int32_t screens_to_read;
17159
17160 589 mapscr temp_mapscr;
17161 word temp_map_count;
17162 dword section_size;
17163
17164
5/6
✓ Branch 0 taken 571 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 565 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
589 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17165 {
17166 18 screens_to_read=MAPSCRS192b136;
17167 18 }
17168 else
17169 {
17170 571 screens_to_read=MAPSCRS;
17171 }
17172
17173
2/2
✓ Branch 0 taken 565 times.
✓ Branch 1 taken 24 times.
589 if(Header->zelda_version > 0x192)
17174 {
17175 //section version info
17176
2/4
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 565 times.
✗ Branch 3 not taken.
565 if(!p_igetw(&version,f))
17177 {
17178 return qe_invalid;
17179 }
17180
17181 565 FFCore.quest_format[vMaps] = version;
17182
17183 //al_trace("Maps version %d\n", version);
17184
2/4
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 565 times.
✗ Branch 3 not taken.
565 if(!p_igetw(&dummy,f))
17185 {
17186 return qe_invalid;
17187 }
17188
17189 //section size
17190
2/4
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 565 times.
✗ Branch 3 not taken.
565 if(!p_igetl(&section_size,f))
17191 {
17192 return qe_invalid;
17193 }
17194
17195 //finally... section data
17196
2/4
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 565 times.
✗ Branch 3 not taken.
565 if(!p_igetw(&temp_map_count,f))
17197 {
17198 return 5;
17199 }
17200 565 }
17201 else
17202 {
17203 24 temp_map_count=map_count;
17204 }
17205
17206
2/4
✓ Branch 0 taken 589 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 589 times.
✗ Branch 3 not taken.
589 if (!(temp_map_count >= 0 && temp_map_count <= MAXMAPS))
17207 {
17208 return qe_invalid;
17209 }
17210
17211
2/2
✓ Branch 0 taken 588 times.
✓ Branch 1 taken 1 times.
589 if (!should_skip)
17212 {
17213 588 const int32_t _mapsSize = MAPSCRS*temp_map_count;
17214
1/2
✓ Branch 0 taken 588 times.
✗ Branch 1 not taken.
588 TheMaps.resize(_mapsSize);
17215 588 map_autolayers.clear();
17216
1/2
✓ Branch 0 taken 588 times.
✗ Branch 1 not taken.
588 map_autolayers.resize(temp_map_count*6);
17217
2/2
✓ Branch 0 taken 863192 times.
✓ Branch 1 taken 588 times.
863780 for(int32_t i(0); i<_mapsSize; i++)
17218
1/2
✓ Branch 0 taken 863192 times.
✗ Branch 1 not taken.
863192 TheMaps[i].zero_memory();
17219 588 }
17220
17221
1/2
✓ Branch 0 taken 589 times.
✗ Branch 1 not taken.
589 temp_mapscr.zero_memory();
17222
17223
4/4
✓ Branch 0 taken 589 times.
✓ Branch 1 taken 6349 times.
✓ Branch 2 taken 589 times.
✓ Branch 3 taken 6349 times.
6938 for(int32_t i=0; i<temp_map_count && i<MAXMAPS; i++)
17224 {
17225 6349 byte valid=1;
17226
2/2
✓ Branch 0 taken 1087 times.
✓ Branch 1 taken 5262 times.
6349 if(version > 22)
17227 {
17228
2/4
✓ Branch 0 taken 1087 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1087 times.
✗ Branch 3 not taken.
1087 if(!p_getc(&valid,f))
17229 return qe_invalid;
17230 1087 }
17231
4/4
✓ Branch 0 taken 6328 times.
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 5394 times.
✓ Branch 3 taken 934 times.
6349 if(valid && version > 25)
17232 {
17233
2/2
✓ Branch 0 taken 5604 times.
✓ Branch 1 taken 934 times.
6538 for(int q = 0; q < 6; ++q)
17234 {
17235
2/4
✓ Branch 0 taken 5604 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5604 times.
✗ Branch 3 not taken.
5604 if(!p_igetw(&map_autolayers[i*6+q],f))
17236 return qe_invalid;
17237 5604 }
17238 934 }
17239
2/2
✓ Branch 0 taken 862792 times.
✓ Branch 1 taken 6349 times.
869141 for(int32_t j=0; j<screens_to_read; j++)
17240 {
17241 862792 scr=i*MAPSCRS+j;
17242
1/2
✓ Branch 0 taken 862792 times.
✗ Branch 1 not taken.
862792 clear_screen(&temp_mapscr);
17243
2/2
✓ Branch 0 taken 859936 times.
✓ Branch 1 taken 2856 times.
862792 if(valid)
17244
1/2
✓ Branch 0 taken 859936 times.
✗ Branch 1 not taken.
859936 readmapscreen(f, Header, &temp_mapscr, version, scr);
17245
17246
2/2
✓ Branch 0 taken 862520 times.
✓ Branch 1 taken 272 times.
862792 if (!should_skip)
17247
1/2
✓ Branch 0 taken 862520 times.
✗ Branch 1 not taken.
862520 TheMaps[scr] = temp_mapscr;
17248 862792 }
17249
17250
2/2
✓ Branch 0 taken 6347 times.
✓ Branch 1 taken 2 times.
6349 if (should_skip)
17251 2 continue;
17252
17253
5/6
✓ Branch 0 taken 6179 times.
✓ Branch 1 taken 168 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 6161 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 18 times.
6347 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17254 {
17255 168 int32_t index = (i*MAPSCRS+132);
17256
17257
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 TheMaps[index]=TheMaps[index-1];
17258
17259 168 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].data, TheMaps[i*MAPSCRS+131].data);
17260 168 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].sflag, TheMaps[i*MAPSCRS+131].sflag);
17261 168 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].cset, TheMaps[i*MAPSCRS+131].cset);
17262
17263
2/2
✓ Branch 0 taken 504 times.
✓ Branch 1 taken 168 times.
672 for(int32_t j=133; j<MAPSCRS; j++)
17264 {
17265 504 scr=i*MAPSCRS+j;
17266
17267
1/2
✓ Branch 0 taken 504 times.
✗ Branch 1 not taken.
504 TheMaps[scr].zero_memory();
17268 504 TheMaps[scr].valid = mVERSION;
17269 504 TheMaps[scr].screen_midi = -1;
17270 504 TheMaps[scr].csensitive = 1;
17271 504 }
17272 168 }
17273
17274
5/6
✓ Branch 0 taken 6179 times.
✓ Branch 1 taken 168 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 6161 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 18 times.
6347 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
17275 {
17276
2/2
✓ Branch 0 taken 22848 times.
✓ Branch 1 taken 168 times.
23016 for(int32_t j=0; j<MAPSCRS; j++)
17277 {
17278 22848 scr=i*MAPSCRS+j;
17279 22848 TheMaps[scr].door_combo_set=MakeDoors(i, j);
17280
17281
2/2
✓ Branch 0 taken 2924544 times.
✓ Branch 1 taken 22848 times.
2947392 for(int32_t k=0; k<128; k++)
17282 {
17283
1/2
✓ Branch 0 taken 2924544 times.
✗ Branch 1 not taken.
2924544 TheMaps[scr].secretcset[k]=tcmbcset2(i, TheMaps[scr].secretcombo[k]);
17284
1/2
✓ Branch 0 taken 2924544 times.
✗ Branch 1 not taken.
2924544 TheMaps[scr].secretflag[k]=tcmbflag2(i, TheMaps[scr].secretcombo[k]);
17285
1/2
✓ Branch 0 taken 2924544 times.
✗ Branch 1 not taken.
2924544 TheMaps[scr].secretcombo[k]=tcmbdat2(i, j, TheMaps[scr].secretcombo[k]);
17286 2924544 }
17287 22848 }
17288 168 }
17289 6347 }
17290 589 map_count = temp_map_count;
17291
1/2
✓ Branch 0 taken 589 times.
✗ Branch 1 not taken.
589 clear_screen(&temp_mapscr);
17292 589 return 0;
17293 589 }
17294
17295
17296 6354035 void update_combo(newcombo& cmb, word section_version)
17297 {
17298
2/2
✓ Branch 0 taken 2085472 times.
✓ Branch 1 taken 4268563 times.
6354035 if(section_version < 40)
17299 {
17300
3/3
✓ Branch 0 taken 3155 times.
✓ Branch 1 taken 32500 times.
✓ Branch 2 taken 4232908 times.
4268563 switch(cmb.type)
17301 {
17302 case cWATER: case cSHALLOWWATER:
17303 32500 cmb.attribytes[6] = iwRipples;
17304 32500 break;
17305 case cTALLGRASS: case cTALLGRASSNEXT: case cTALLGRASSTOUCHY:
17306 3155 cmb.attribytes[6] = iwTallGrass;
17307 3155 break;
17308 }
17309 4268563 }
17310 6354035 }
17311 200 int32_t readcombos_old(word section_version, PACKFILE *f, zquestheader *, word version, word build, word start_combo, word max_combos)
17312 {
17313
2/2
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 24 times.
200 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_combos);
17314
17315
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 199 times.
200 if (!should_skip)
17316 {
17317 199 reset_combo_animations();
17318 199 reset_combo_animations2();
17319 199 init_combo_classes();
17320 199 }
17321
17322 // combos
17323 200 word combos_used=0;
17324 int32_t dummy;
17325 byte padding;
17326 200 newcombo temp_combo;
17327 //word section_cversion=0;
17328
17329
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 199 times.
200 if (!should_skip)
17330
2/2
✓ Branch 0 taken 12990720 times.
✓ Branch 1 taken 199 times.
12990919 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
17331
1/2
✓ Branch 0 taken 12990720 times.
✗ Branch 1 not taken.
12990919 combobuf[q].clear();
17332
17333 // if(version > 0x192)
17334 // {
17335 // //section version info
17336 // if(!p_igetw(&section_version,f))
17337 // {
17338 // return qe_invalid;
17339 // }
17340
17341 // FFCore.quest_format[vCombos] = section_version;
17342
17343 // //al_trace("Combos version %d\n", section_version);
17344 // if(!p_igetw(&section_cversion,f))
17345 // {
17346 // return qe_invalid;
17347 // }
17348
17349 // //section size
17350 // if(!p_igetl(&dummy,f))
17351 // {
17352 // return qe_invalid;
17353 // }
17354 // }
17355
17356
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(version < 0x174)
17357 {
17358 combos_used=1024;
17359 }
17360
2/2
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 18 times.
200 else if(version < 0x191)
17361 {
17362 18 combos_used=2048;
17363 18 }
17364 else
17365 {
17366
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
182 if(!p_igetw(&combos_used,f))
17367 {
17368 return qe_invalid;
17369 }
17370 }
17371
17372 //finally... section data
17373
2/2
✓ Branch 0 taken 4133547 times.
✓ Branch 1 taken 200 times.
4133747 for(int32_t i=0; i<combos_used; i++)
17374 {
17375
1/2
✓ Branch 0 taken 4133547 times.
✗ Branch 1 not taken.
4133547 temp_combo.clear();
17376
17377
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 3930579 times.
4133547 if ( section_version >= 11 )
17378 {
17379
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_combo.tile,f))
17380 {
17381 return qe_invalid;
17382 }
17383 202968 }
17384 else
17385 {
17386
2/4
✓ Branch 0 taken 3930579 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3930579 times.
✗ Branch 3 not taken.
3930579 if(!p_igetw(&temp_combo.tile,f))
17387 {
17388 return qe_invalid;
17389 }
17390 }
17391 4133547 temp_combo.o_tile = temp_combo.tile;
17392
2/4
✓ Branch 0 taken 4133547 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4133547 times.
✗ Branch 3 not taken.
4133547 if(!p_getc(&temp_combo.flip,f))
17393 {
17394 return qe_invalid;
17395 }
17396
17397
2/4
✓ Branch 0 taken 4133547 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4133547 times.
✗ Branch 3 not taken.
4133547 if(!p_getc(&temp_combo.walk,f))
17398 {
17399 return qe_invalid;
17400 }
17401
17402
2/4
✓ Branch 0 taken 4133547 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4133547 times.
✗ Branch 3 not taken.
4133547 if(!p_getc(&temp_combo.type,f))
17403 {
17404 return qe_invalid;
17405 }
17406
17407
2/4
✓ Branch 0 taken 4133547 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4133547 times.
✗ Branch 3 not taken.
4133547 if(!p_getc(&temp_combo.csets,f))
17408 {
17409 return qe_invalid;
17410 }
17411
17412
2/2
✓ Branch 0 taken 69774 times.
✓ Branch 1 taken 4063773 times.
4133547 if(version < 0x193)
17413 {
17414
2/4
✓ Branch 0 taken 69774 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 69774 times.
✗ Branch 3 not taken.
69774 if(!p_getc(&padding,f))
17415 return qe_invalid;
17416
17417
2/4
✓ Branch 0 taken 69774 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 69774 times.
✗ Branch 3 not taken.
69774 if(!p_getc(&padding,f))
17418 return qe_invalid;
17419
17420
2/2
✓ Branch 0 taken 32910 times.
✓ Branch 1 taken 36864 times.
69774 if(version < 0x192)
17421 {
17422
1/2
✓ Branch 0 taken 36864 times.
✗ Branch 1 not taken.
36864 if(version == 0x191)
17423 {
17424 for(int32_t tmpcounter=0; tmpcounter<16; tmpcounter++)
17425 {
17426 if(!p_getc(&padding,f))
17427 return qe_invalid;
17428 }
17429 }
17430 36864 }
17431 69774 }
17432
2/2
✓ Branch 0 taken 4096683 times.
✓ Branch 1 taken 36864 times.
4133547 if(version >= 0x192)
17433 {
17434
2/4
✓ Branch 0 taken 4096683 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4096683 times.
✗ Branch 3 not taken.
4096683 if(!p_getc(&temp_combo.frames,f))
17435 return qe_invalid;
17436
17437
2/4
✓ Branch 0 taken 4096683 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4096683 times.
✗ Branch 3 not taken.
4096683 if(!p_getc(&temp_combo.speed,f))
17438 return qe_invalid;
17439
17440
2/4
✓ Branch 0 taken 4096683 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4096683 times.
✗ Branch 3 not taken.
4096683 if(!p_igetw(&temp_combo.nextcombo,f))
17441 return qe_invalid;
17442
17443
2/4
✓ Branch 0 taken 4096683 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4096683 times.
✗ Branch 3 not taken.
4096683 if(!p_getc(&temp_combo.nextcset,f))
17444 return qe_invalid;
17445
17446 //Base flag
17447
2/2
✓ Branch 0 taken 2319319 times.
✓ Branch 1 taken 1777364 times.
4096683 if(section_version>=3)
17448
2/4
✓ Branch 0 taken 2319319 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2319319 times.
✗ Branch 3 not taken.
2319319 if(!p_getc(&temp_combo.flag,f))
17449 return qe_invalid;
17450
17451
2/2
✓ Branch 0 taken 2319319 times.
✓ Branch 1 taken 1777364 times.
4096683 if(section_version>=4)
17452 {
17453
2/4
✓ Branch 0 taken 2319319 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2319319 times.
✗ Branch 3 not taken.
2319319 if(!p_getc(&temp_combo.skipanim,f))
17454 return qe_invalid;
17455
17456
2/4
✓ Branch 0 taken 2319319 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2319319 times.
✗ Branch 3 not taken.
2319319 if(!p_igetw(&temp_combo.nexttimer,f))
17457 return qe_invalid;
17458 2319319 }
17459
17460
2/2
✓ Branch 0 taken 2319319 times.
✓ Branch 1 taken 1777364 times.
4096683 if(section_version>=5)
17461
2/4
✓ Branch 0 taken 2319319 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2319319 times.
✗ Branch 3 not taken.
2319319 if(!p_getc(&temp_combo.skipanimy,f))
17462 return qe_invalid;
17463
17464
2/2
✓ Branch 0 taken 2319319 times.
✓ Branch 1 taken 1777364 times.
4096683 if(section_version>=6)
17465 {
17466
2/4
✓ Branch 0 taken 2319319 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2319319 times.
✗ Branch 3 not taken.
2319319 if(!p_getc(&temp_combo.animflags,f))
17467 return qe_invalid;
17468
17469
1/2
✓ Branch 0 taken 2319319 times.
✗ Branch 1 not taken.
2319319 if(section_version == 6)
17470 temp_combo.animflags = temp_combo.animflags ? AF_FRESH : 0;
17471 2319319 }
17472
17473
2/2
✓ Branch 0 taken 3893715 times.
✓ Branch 1 taken 202968 times.
4096683 if(section_version>=8) //combo Attributes[4] and userflags.
17474 {
17475
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 811872 times.
1014840 for ( int32_t q = 0; q < NUM_COMBO_ATTRIBUTES; q++ )
17476
2/4
✓ Branch 0 taken 811872 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 811872 times.
✗ Branch 3 not taken.
811872 if(!p_igetl(&temp_combo.attributes[q],f))
17477 return qe_invalid;
17478
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_combo.usrflags,f))
17479 return qe_invalid;
17480
1/2
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
202968 if(section_version >= 20)
17481
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetw(&temp_combo.genflags,f))
17482 return qe_invalid;
17483 202968 }
17484
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 3893715 times.
4096683 if(section_version>=10) //combo trigger flags
17485 {
17486
2/2
✓ Branch 0 taken 608904 times.
✓ Branch 1 taken 202968 times.
811872 for ( int32_t q = 0; q < 3; q++ )
17487
2/4
✓ Branch 0 taken 608904 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 608904 times.
✗ Branch 3 not taken.
608904 if(!p_igetl(&temp_combo.triggerflags[q],f))
17488 return qe_invalid;
17489 202968 }
17490
1/2
✓ Branch 0 taken 3893715 times.
✗ Branch 1 not taken.
3893715 else if(section_version==9) //combo trigger flags, V9 only had two indices of triggerflags[]
17491 {
17492 for ( int32_t q = 0; q < 2; q++ )
17493 if(!p_igetl(&temp_combo.triggerflags[q],f))
17494 return qe_invalid;
17495 }
17496
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 3893715 times.
4096683 if(section_version >= 9)
17497
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_combo.triggerlevel,f))
17498 return qe_invalid;
17499
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 3893715 times.
4096683 if(section_version >= 22)
17500
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_getc(&temp_combo.triggerbtn,f))
17501 return qe_invalid;
17502
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4096683 times.
4096683 if(section_version >= 24)
17503 {
17504 if(!p_getc(&temp_combo.triggeritem,f))
17505 return qe_invalid;
17506 if(!p_getc(&temp_combo.trigtimer,f))
17507 return qe_invalid;
17508 }
17509
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4096683 times.
4096683 if(section_version >= 25)
17510 if(!p_getc(&temp_combo.trigsfx,f))
17511 return qe_invalid;
17512
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4096683 times.
4096683 if(section_version >= 27)
17513 if(!p_igetl(&temp_combo.trigchange,f))
17514 return qe_invalid;
17515
17516
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4096683 times.
4096683 if(section_version >= 29)
17517 {
17518 if(!p_igetw(&temp_combo.trigprox,f))
17519 return qe_invalid;
17520 if(!p_getc(&temp_combo.trigctr,f))
17521 return qe_invalid;
17522 if(!p_igetl(&temp_combo.trigctramnt,f))
17523 return qe_invalid;
17524 }
17525
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4096683 times.
4096683 if(section_version >= 30)
17526 if(!p_getc(&temp_combo.triglbeam,f))
17527 return qe_invalid;
17528
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4096683 times.
4096683 if(section_version >= 31)
17529 {
17530 if(!p_getc(&temp_combo.trigcschange,f))
17531 return qe_invalid;
17532 if(!p_igetw(&temp_combo.spawnitem,f))
17533 return qe_invalid;
17534 if(!p_igetw(&temp_combo.spawnenemy,f))
17535 return qe_invalid;
17536 if(!p_getc(&temp_combo.exstate,f))
17537 return qe_invalid;
17538 if(!p_igetl(&temp_combo.spawnip,f))
17539 return qe_invalid;
17540 if(!p_getc(&temp_combo.trigcopycat,f))
17541 return qe_invalid;
17542 }
17543
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4096683 times.
4096683 if(section_version >= 32)
17544 if(!p_getc(&temp_combo.trigcooldown,f))
17545 return qe_invalid;
17546
17547
2/2
✓ Branch 0 taken 3893715 times.
✓ Branch 1 taken 202968 times.
4096683 if(section_version>=12) //combo label
17548 {
17549 char label[12];
17550 202968 label[11] = '\0';
17551
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 2232648 times.
2435616 for ( int32_t q = 0; q < 11; q++ )
17552
2/4
✓ Branch 0 taken 2232648 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2232648 times.
✗ Branch 3 not taken.
2232648 if(!p_getc(&label[q],f))
17553 return qe_invalid;
17554
1/2
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
202968 temp_combo.label = label;
17555 202968 }
17556
2/2
✓ Branch 0 taken 3893715 times.
✓ Branch 1 taken 202968 times.
4096683 if(section_version>=13) //attribytes[4]
17557
2/2
✓ Branch 0 taken 811872 times.
✓ Branch 1 taken 202968 times.
1014840 for ( int32_t q = 0; q < 4; q++ )
17558
2/4
✓ Branch 0 taken 811872 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 811872 times.
✗ Branch 3 not taken.
811872 if(!p_getc(&temp_combo.attribytes[q],f))
17559 202968 return qe_invalid;
17560 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
17561 * This fixes a poor implementation of a ->next flag bug thing.
17562 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
17563 * there was a version bump a few weeks before a change that broke stuff.
17564 */
17565
3/4
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 3893715 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 202968 times.
4096683 if (section_version >= 13 && section_version < 21)
17566 {
17567 set_qr(qr_BUGGY_BUGGY_SLASH_TRIGGERS,1);
17568 }
17569 //combo scripts
17570
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 3893715 times.
4096683 if(section_version>=14)
17571 {
17572
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetw(&temp_combo.script,f))
17573 return qe_invalid;
17574
2/2
✓ Branch 0 taken 405936 times.
✓ Branch 1 taken 202968 times.
608904 for ( int32_t q = 0; q < 2; q++ )
17575
2/4
✓ Branch 0 taken 405936 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405936 times.
✗ Branch 3 not taken.
405936 if(!p_igetl(&temp_combo.initd[q],f))
17576 return qe_invalid;
17577 202968 }
17578 //al_trace("Read combo script data\n");
17579
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 3893715 times.
4096683 if(section_version>=15)
17580 {
17581
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_combo.o_tile,f)) return qe_invalid;
17582
2/2
✓ Branch 0 taken 107633 times.
✓ Branch 1 taken 95335 times.
202968 if(!temp_combo.o_tile) temp_combo.o_tile = temp_combo.tile;
17583
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_getc(&temp_combo.cur_frame,f)) return qe_invalid;
17584
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_getc(&temp_combo.aclk,f)) return qe_invalid;
17585 202968 }
17586
2/2
✓ Branch 0 taken 3893715 times.
✓ Branch 1 taken 202968 times.
4096683 if(section_version>=17) //attribytes[4]
17587 {
17588
2/2
✓ Branch 0 taken 811872 times.
✓ Branch 1 taken 202968 times.
1014840 for ( int32_t q = 4; q < 8; q++ ) //bump up attribytes...
17589
2/4
✓ Branch 0 taken 811872 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 811872 times.
✗ Branch 3 not taken.
811872 if(!p_getc(&temp_combo.attribytes[q],f))
17590 return qe_invalid;
17591
2/2
✓ Branch 0 taken 1623744 times.
✓ Branch 1 taken 202968 times.
1826712 for ( int32_t q = 0; q < 8; q++ ) //...and add attrishorts
17592
2/4
✓ Branch 0 taken 1623744 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1623744 times.
✗ Branch 3 not taken.
1623744 if(!p_igetw(&temp_combo.attrishorts[q],f))
17593 return qe_invalid;
17594 202968 }
17595
17596
2/2
✓ Branch 0 taken 4063773 times.
✓ Branch 1 taken 32910 times.
4096683 if(version < 0x193)
17597
2/2
✓ Branch 0 taken 362010 times.
✓ Branch 1 taken 32910 times.
394920 for(int32_t q=0; q<11; q++)
17598
2/4
✓ Branch 0 taken 362010 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 362010 times.
✗ Branch 3 not taken.
362010 if(!p_getc(&dummy,f))
17599 32910 return qe_invalid;
17600 4096683 }
17601
17602 //Goriya tiles were flipped around in 2.11 build 7. Compensate for the flip here. -DD
17603
3/6
✓ Branch 0 taken 2319319 times.
✓ Branch 1 taken 1814228 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2319319 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4133547 if((version < 0x211)||((version == 0x211)&&(build<7)))
17604 {
17605
2/2
✓ Branch 0 taken 1774292 times.
✓ Branch 1 taken 39936 times.
1814228 if(!get_qr(qr_NEWENEMYTILES))
17606 {
17607
1/5
✓ Branch 0 taken 39936 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
39936 switch(temp_combo.tile)
17608 {
17609 case 130:
17610 temp_combo.tile = 132;
17611 break;
17612
17613 case 131:
17614 temp_combo.tile = 133;
17615 break;
17616
17617 case 132:
17618 temp_combo.tile = 130;
17619 break;
17620
17621 case 133:
17622 temp_combo.tile = 131;
17623 break;
17624 }
17625 39936 }
17626 1814228 }
17627
17628
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 3930579 times.
4133547 if(section_version < 15)
17629 3930579 temp_combo.o_tile = temp_combo.tile;
17630
17631
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 3930579 times.
4133547 if(section_version<18) //upper bits for .walk
17632 3930579 temp_combo.walk |= 0xF0;
17633
17634
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 3930579 times.
4133547 if(section_version < 19)
17635
2/2
✓ Branch 0 taken 15722316 times.
✓ Branch 1 taken 3930579 times.
19652895 for(int32_t q = 0; q < 4; ++q)
17636 19652895 temp_combo.attributes[q] *= 10000L;
17637
17638
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4133547 times.
4133547 if(section_version < 23)
17639 {
17640
2/2
✓ Branch 0 taken 6531 times.
✓ Branch 1 taken 4127016 times.
4133547 switch(temp_combo.type) //combotriggerCMBTYPEFX now required for combotype-specific effects
17641 {
17642 case cSCRIPT1: case cSCRIPT2: case cSCRIPT3: case cSCRIPT4: case cSCRIPT5:
17643 case cSCRIPT6: case cSCRIPT7: case cSCRIPT8: case cSCRIPT9: case cSCRIPT10:
17644 case cTRIGGERGENERIC: case cCSWITCH:
17645 6531 temp_combo.triggerflags[0] |= combotriggerCMBTYPEFX;
17646 6531 }
17647 4133547 }
17648
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4133547 times.
4133547 if(section_version < 25)
17649 {
17650
2/2
✓ Branch 0 taken 14593 times.
✓ Branch 1 taken 4118954 times.
4133547 switch(temp_combo.type)
17651 {
17652 case cLOCKBLOCK: case cBOSSLOCKBLOCK:
17653
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14593 times.
14593 if(!(temp_combo.usrflags & cflag3))
17654 14593 temp_combo.attribytes[3] = WAV_DOOR;
17655 14593 temp_combo.usrflags &= ~cflag3;
17656 14593 break;
17657 }
17658 4133547 }
17659
17660
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4133547 times.
4133547 if(section_version < 26)
17661
2/2
✓ Branch 0 taken 4132667 times.
✓ Branch 1 taken 880 times.
4134427 if(temp_combo.type == cARMOS)
17662
1/2
✓ Branch 0 taken 880 times.
✗ Branch 1 not taken.
880 if(temp_combo.usrflags & cflag1)
17663 temp_combo.usrflags |= cflag3;
17664
17665
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4133547 times.
4133547 if(section_version < 27)
17666 {
17667
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4133547 times.
4133547 if(temp_combo.triggerflags[0] & 0x00040000) //'next'
17668 temp_combo.trigchange = 1;
17669
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4133547 times.
4133547 else if(temp_combo.triggerflags[0] & 0x00080000) //'prev'
17670 temp_combo.trigchange = -1;
17671 4133547 else temp_combo.trigchange = 0;
17672 4133547 temp_combo.triggerflags[0] &= ~(0x00040000|0x00080000);
17673 4133547 }
17674
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4133547 times.
4133547 if(section_version < 28)
17675 {
17676
2/2
✓ Branch 0 taken 8183 times.
✓ Branch 1 taken 4125364 times.
4133547 switch(temp_combo.type)
17677 {
17678 case cLOCKBLOCK: case cLOCKEDCHEST:
17679
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8183 times.
8183 if(temp_combo.usrflags & cflag7)
17680 temp_combo.usrflags |= cflag8;
17681 8183 else temp_combo.usrflags &= ~cflag8;
17682 8183 temp_combo.usrflags &= ~cflag7;
17683 8183 break;
17684 }
17685
2/2
✓ Branch 0 taken 436 times.
✓ Branch 1 taken 4133111 times.
4133547 switch(temp_combo.type)
17686 {
17687 case cCHEST: case cLOCKEDCHEST: case cBOSSCHEST:
17688 436 temp_combo.attrishorts[2] = -1;
17689 436 temp_combo.usrflags |= cflag7;
17690 436 break;
17691 }
17692 4133547 }
17693
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 3930579 times.
4133547 if(section_version < 20)
17694 {
17695 3930579 temp_combo.genflags = 0;
17696
2/2
✓ Branch 0 taken 73002 times.
✓ Branch 1 taken 3857577 times.
3930579 switch(temp_combo.type)
17697 {
17698 case cPUSH_WAIT: case cPUSH_HEAVY:
17699 case cPUSH_HW: case cL_STATUE:
17700 case cR_STATUE: case cPUSH_HEAVY2:
17701 case cPUSH_HW2: case cPOUND:
17702 case cC_STATUE: case cMIRROR:
17703 case cMIRRORSLASH: case cMIRRORBACKSLASH:
17704 case cMAGICPRISM: case cMAGICPRISM4:
17705 case cMAGICSPONGE: case cEYEBALL_A:
17706 case cEYEBALL_B: case cEYEBALL_4:
17707 case cBUSH: case cFLOWERS:
17708 case cLOCKBLOCK: case cLOCKBLOCK2:
17709 case cBOSSLOCKBLOCK: case cBOSSLOCKBLOCK2:
17710 case cCHEST: case cCHEST2:
17711 case cLOCKEDCHEST: case cLOCKEDCHEST2:
17712 case cBOSSCHEST: case cBOSSCHEST2:
17713 case cBUSHNEXT: case cBUSHTOUCHY:
17714 case cFLOWERSTOUCHY: case cBUSHNEXTTOUCHY:
17715 case cSIGNPOST: case cCSWITCHBLOCK:
17716 case cTORCH: case cTRIGGERGENERIC:
17717
1/2
✓ Branch 0 taken 73002 times.
✗ Branch 1 not taken.
73002 if(temp_combo.usrflags & cflag16)
17718 {
17719 temp_combo.genflags |= cflag1;
17720 temp_combo.usrflags &= ~cflag16;
17721 }
17722 73002 break;
17723 }
17724 3930579 }
17725
17726 4133547 update_combo(temp_combo, section_version);
17727
17728
3/4
✓ Branch 0 taken 4133547 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4118628 times.
✓ Branch 3 taken 14919 times.
4133547 if(i>=start_combo && !should_skip)
17729 {
17730
1/2
✓ Branch 0 taken 4118628 times.
✗ Branch 1 not taken.
4118628 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
17731 {
17732 temp_combo.script = 0;
17733 for(int q = 0; q < 8; ++q)
17734 temp_combo.initd[q] = 0;
17735 }
17736
1/2
✓ Branch 0 taken 4118628 times.
✗ Branch 1 not taken.
4118628 combobuf[i] = temp_combo;
17737 4118628 }
17738 4133547 }
17739
17740
2/2
✓ Branch 0 taken 199 times.
✓ Branch 1 taken 1 times.
200 if (should_skip)
17741 1 return 0;
17742
17743
5/6
✓ Branch 0 taken 181 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 176 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
199 if((version < 0x192)|| ((version == 0x192)&&(build<185)))
17744 {
17745
2/2
✓ Branch 0 taken 1501440 times.
✓ Branch 1 taken 23 times.
1501463 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17746 {
17747
2/2
✓ Branch 0 taken 1501225 times.
✓ Branch 1 taken 215 times.
1501440 if(combobuf[tmpcounter].type==cHOOKSHOTONLY)
17748 {
17749 215 combobuf[tmpcounter].type=cLADDERHOOKSHOT;
17750 215 }
17751 1501440 }
17752 23 }
17753
17754 //June 3 2012; ladder only is broken in 2.10 and allows the hookshot also. -Gleeok
17755
4/6
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 160 times.
✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 39 times.
199 if(version == 0x210 && !is_editor())
17756 {
17757
2/2
✓ Branch 0 taken 2545920 times.
✓ Branch 1 taken 39 times.
2545959 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17758
2/2
✓ Branch 0 taken 2545816 times.
✓ Branch 1 taken 104 times.
2546024 if(combobuf[tmpcounter].type == cLADDERONLY)
17759 104 combobuf[tmpcounter].type = cLADDERHOOKSHOT;
17760 39 }
17761
17762
2/2
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 62 times.
199 if(section_version<7)
17763 {
17764
2/2
✓ Branch 0 taken 4047360 times.
✓ Branch 1 taken 62 times.
4047422 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17765 {
17766
6/9
✓ Branch 0 taken 4045353 times.
✓ Branch 1 taken 574 times.
✓ Branch 2 taken 539 times.
✓ Branch 3 taken 410 times.
✓ Branch 4 taken 137 times.
✓ Branch 5 taken 347 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
4047360 switch(combobuf[tmpcounter].type)
17767 {
17768 case cSLASH:
17769 574 combobuf[tmpcounter].type=cSLASHTOUCHY;
17770 574 break;
17771
17772 case cSLASHITEM:
17773 539 combobuf[tmpcounter].type=cSLASHITEMTOUCHY;
17774 539 break;
17775
17776 case cBUSH:
17777 410 combobuf[tmpcounter].type=cBUSHTOUCHY;
17778 410 break;
17779
17780 case cFLOWERS:
17781 137 combobuf[tmpcounter].type=cFLOWERSTOUCHY;
17782 137 break;
17783
17784 case cTALLGRASS:
17785 347 combobuf[tmpcounter].type=cTALLGRASSTOUCHY;
17786 347 break;
17787
17788 case cSLASHNEXT:
17789 combobuf[tmpcounter].type=cSLASHNEXTTOUCHY;
17790 break;
17791
17792 case cSLASHNEXTITEM:
17793 combobuf[tmpcounter].type=cSLASHNEXTITEMTOUCHY;
17794 break;
17795
17796 case cBUSHNEXT:
17797 combobuf[tmpcounter].type=cBUSHNEXTTOUCHY;
17798 break;
17799 }
17800 4047360 }
17801 62 }
17802
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 194 times.
199 if (section_version < 16)
17803 {
17804
2/2
✓ Branch 0 taken 12664320 times.
✓ Branch 1 taken 194 times.
12664514 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17805 {
17806
2/2
✓ Branch 0 taken 12645025 times.
✓ Branch 1 taken 19295 times.
12664320 if (combobuf[tmpcounter].type == cWATER)
17807 {
17808 19295 combobuf[tmpcounter].attributes[0] = 40000L;
17809 19295 }
17810 12664320 }
17811 194 }
17812
2/2
✓ Branch 0 taken 196 times.
✓ Branch 1 taken 3 times.
199 if(!get_qr(qr_ALLOW_EDITING_COMBO_0))
17813 {
17814 3 combobuf[0].walk = 0xF0;
17815 3 combobuf[0].type = 0;
17816 3 combobuf[0].flag = 0;
17817 3 }
17818
17819 //Now for the new combo alias reset
17820
2/2
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 62 times.
199 if(section_version<2)
17821 {
17822
2/2
✓ Branch 0 taken 507904 times.
✓ Branch 1 taken 62 times.
507966 for(int32_t j=0; j<MAXCOMBOALIASES; j++)
17823 {
17824 507904 combo_aliases[j].width = 0;
17825 507904 combo_aliases[j].height = 0;
17826 507904 combo_aliases[j].layermask = 0;
17827
1/2
✓ Branch 0 taken 507904 times.
✗ Branch 1 not taken.
507904 combo_aliases[j].combos.clear();
17828
1/2
✓ Branch 0 taken 507904 times.
✗ Branch 1 not taken.
507904 combo_aliases[j].csets.clear();
17829 507904 }
17830 62 }
17831
17832
17833
1/2
✓ Branch 0 taken 199 times.
✗ Branch 1 not taken.
199 setup_combo_animations();
17834
1/2
✓ Branch 0 taken 199 times.
✗ Branch 1 not taken.
199 setup_combo_animations2();
17835 199 return 0;
17836 200 }
17837 2220488 int32_t readcombo_loop(PACKFILE* f, word s_version, newcombo& temp_combo)
17838 {
17839 byte combo_has_flags;
17840
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2220488 times.
2220488 if(!p_getc(&combo_has_flags,f))
17841 return qe_invalid;
17842
17843 2220488 temp_combo.clear();
17844
2/2
✓ Branch 0 taken 1567276 times.
✓ Branch 1 taken 653212 times.
2220488 if(combo_has_flags)
17845 {
17846
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 653185 times.
653212 if(combo_has_flags&CHAS_BASIC)
17847 {
17848
1/2
✓ Branch 0 taken 653185 times.
✗ Branch 1 not taken.
653185 if(!p_igetl(&temp_combo.tile,f))
17849 return qe_invalid;
17850 653185 temp_combo.o_tile = temp_combo.tile;
17851
17852
1/2
✓ Branch 0 taken 653185 times.
✗ Branch 1 not taken.
653185 if(!p_getc(&temp_combo.flip,f))
17853 return qe_invalid;
17854
17855
1/2
✓ Branch 0 taken 653185 times.
✗ Branch 1 not taken.
653185 if(!p_getc(&temp_combo.walk,f))
17856 return qe_invalid;
17857
17858
1/2
✓ Branch 0 taken 653185 times.
✗ Branch 1 not taken.
653185 if(!p_getc(&temp_combo.type,f))
17859 return qe_invalid;
17860
17861
1/2
✓ Branch 0 taken 653185 times.
✗ Branch 1 not taken.
653185 if(!p_getc(&temp_combo.flag,f))
17862 return qe_invalid;
17863
17864
1/2
✓ Branch 0 taken 653185 times.
✗ Branch 1 not taken.
653185 if(!p_getc(&temp_combo.csets,f))
17865 return qe_invalid;
17866 653185 }
17867
2/2
✓ Branch 0 taken 651641 times.
✓ Branch 1 taken 1571 times.
653212 if(combo_has_flags&CHAS_SCRIPT)
17868 {
17869
2/2
✓ Branch 0 taken 1541 times.
✓ Branch 1 taken 30 times.
1571 if (s_version>=41)
17870 {
17871 1541 p_getcstr(&temp_combo.label, f);
17872 1541 }
17873 else
17874 {
17875 char label[12];
17876 30 label[11] = '\0';
17877
2/2
✓ Branch 0 taken 330 times.
✓ Branch 1 taken 30 times.
360 for ( int32_t q = 0; q < 11; q++ )
17878
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 330 times.
330 if(!p_getc(&label[q],f))
17879 return qe_invalid;
17880 30 temp_combo.label = label;
17881 }
17882
17883
1/2
✓ Branch 0 taken 1571 times.
✗ Branch 1 not taken.
1571 if(!p_igetw(&temp_combo.script,f)) return qe_invalid;
17884 1571 auto initd_count = s_version >= 43 ? 8 : 2;
17885
2/2
✓ Branch 0 taken 12388 times.
✓ Branch 1 taken 1571 times.
13959 for ( int32_t q = 0; q < initd_count; q++ )
17886
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12388 times.
12388 if(!p_igetl(&temp_combo.initd[q],f))
17887 return qe_invalid;
17888 1571 }
17889
2/2
✓ Branch 0 taken 517400 times.
✓ Branch 1 taken 135812 times.
653212 if(combo_has_flags&CHAS_ANIM)
17890 {
17891
1/2
✓ Branch 0 taken 135812 times.
✗ Branch 1 not taken.
135812 if(!p_getc(&temp_combo.frames,f))
17892 return qe_invalid;
17893
17894
1/2
✓ Branch 0 taken 135812 times.
✗ Branch 1 not taken.
135812 if(!p_getc(&temp_combo.speed,f))
17895 return qe_invalid;
17896
17897
1/2
✓ Branch 0 taken 135812 times.
✗ Branch 1 not taken.
135812 if(!p_igetw(&temp_combo.nextcombo,f))
17898 return qe_invalid;
17899
17900
1/2
✓ Branch 0 taken 135812 times.
✗ Branch 1 not taken.
135812 if(!p_getc(&temp_combo.nextcset,f))
17901 return qe_invalid;
17902
17903
1/2
✓ Branch 0 taken 135812 times.
✗ Branch 1 not taken.
135812 if(!p_getc(&temp_combo.skipanim,f))
17904 return qe_invalid;
17905
17906
1/2
✓ Branch 0 taken 135812 times.
✗ Branch 1 not taken.
135812 if(!p_getc(&temp_combo.skipanimy,f))
17907 return qe_invalid;
17908
17909
1/2
✓ Branch 0 taken 135812 times.
✗ Branch 1 not taken.
135812 if(!p_getc(&temp_combo.animflags,f))
17910 return qe_invalid;
17911 135812 }
17912
2/2
✓ Branch 0 taken 577753 times.
✓ Branch 1 taken 75459 times.
653212 if(combo_has_flags&CHAS_ATTRIB)
17913 {
17914
2/2
✓ Branch 0 taken 301836 times.
✓ Branch 1 taken 75459 times.
377295 for ( int32_t q = 0; q < 4; q++ )
17915
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 301836 times.
301836 if(!p_igetl(&temp_combo.attributes[q],f))
17916 return qe_invalid;
17917
2/2
✓ Branch 0 taken 603672 times.
✓ Branch 1 taken 75459 times.
679131 for ( int32_t q = 0; q < 8; q++ )
17918
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 603672 times.
603672 if(!p_getc(&temp_combo.attribytes[q],f))
17919 return qe_invalid;
17920
2/2
✓ Branch 0 taken 603672 times.
✓ Branch 1 taken 75459 times.
679131 for ( int32_t q = 0; q < 8; q++ )
17921
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 603672 times.
603672 if(!p_igetw(&temp_combo.attrishorts[q],f))
17922 return qe_invalid;
17923 75459 }
17924
2/2
✓ Branch 0 taken 627264 times.
✓ Branch 1 taken 25948 times.
653212 if(combo_has_flags&CHAS_FLAG)
17925 {
17926
1/2
✓ Branch 0 taken 25948 times.
✗ Branch 1 not taken.
25948 if(!p_igetl(&temp_combo.usrflags,f))
17927 return qe_invalid;
17928
1/2
✓ Branch 0 taken 25948 times.
✗ Branch 1 not taken.
25948 if(!p_igetw(&temp_combo.genflags,f))
17929 return qe_invalid;
17930 25948 }
17931
2/2
✓ Branch 0 taken 640462 times.
✓ Branch 1 taken 12750 times.
653212 if(combo_has_flags&CHAS_TRIG)
17932 {
17933 12750 int numtrigs = s_version < 36 ? 3 : 6;
17934
2/2
✓ Branch 0 taken 75642 times.
✓ Branch 1 taken 12750 times.
88392 for ( int32_t q = 0; q < numtrigs; q++ )
17935
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75642 times.
75642 if(!p_igetl(&temp_combo.triggerflags[q],f))
17936 return qe_invalid;
17937
1/2
✓ Branch 0 taken 12750 times.
✗ Branch 1 not taken.
12750 if(!p_igetl(&temp_combo.triggerlevel,f))
17938 return qe_invalid;
17939
1/2
✓ Branch 0 taken 12750 times.
✗ Branch 1 not taken.
12750 if(!p_getc(&temp_combo.triggerbtn,f))
17940 return qe_invalid;
17941
1/2
✓ Branch 0 taken 12750 times.
✗ Branch 1 not taken.
12750 if(!p_getc(&temp_combo.triggeritem,f))
17942 return qe_invalid;
17943
1/2
✓ Branch 0 taken 12750 times.
✗ Branch 1 not taken.
12750 if(!p_getc(&temp_combo.trigtimer,f))
17944 return qe_invalid;
17945
1/2
✓ Branch 0 taken 12750 times.
✗ Branch 1 not taken.
12750 if(!p_getc(&temp_combo.trigsfx,f))
17946 return qe_invalid;
17947
1/2
✓ Branch 0 taken 12750 times.
✗ Branch 1 not taken.
12750 if(!p_igetl(&temp_combo.trigchange,f))
17948 return qe_invalid;
17949
1/2
✓ Branch 0 taken 12750 times.
✗ Branch 1 not taken.
12750 if(!p_igetw(&temp_combo.trigprox,f))
17950 return qe_invalid;
17951
1/2
✓ Branch 0 taken 12750 times.
✗ Branch 1 not taken.
12750 if(!p_getc(&temp_combo.trigctr,f))
17952 return qe_invalid;
17953
1/2
✓ Branch 0 taken 12750 times.
✗ Branch 1 not taken.
12750 if(!p_igetl(&temp_combo.trigctramnt,f))
17954 return qe_invalid;
17955
1/2
✓ Branch 0 taken 12750 times.
✗ Branch 1 not taken.
12750 if(!p_getc(&temp_combo.triglbeam,f))
17956 return qe_invalid;
17957
1/2
✓ Branch 0 taken 12750 times.
✗ Branch 1 not taken.
12750 if(!p_getc(&temp_combo.trigcschange,f))
17958 return qe_invalid;
17959
1/2
✓ Branch 0 taken 12750 times.
✗ Branch 1 not taken.
12750 if(!p_igetw(&temp_combo.spawnitem,f))
17960 return qe_invalid;
17961
1/2
✓ Branch 0 taken 12750 times.
✗ Branch 1 not taken.
12750 if(!p_igetw(&temp_combo.spawnenemy,f))
17962 return qe_invalid;
17963
1/2
✓ Branch 0 taken 12750 times.
✗ Branch 1 not taken.
12750 if(!p_getc(&temp_combo.exstate,f))
17964 return qe_invalid;
17965
1/2
✓ Branch 0 taken 12750 times.
✗ Branch 1 not taken.
12750 if(!p_igetl(&temp_combo.spawnip,f))
17966 return qe_invalid;
17967
1/2
✓ Branch 0 taken 12750 times.
✗ Branch 1 not taken.
12750 if(!p_getc(&temp_combo.trigcopycat,f))
17968 return qe_invalid;
17969
1/2
✓ Branch 0 taken 12750 times.
✗ Branch 1 not taken.
12750 if(!p_getc(&temp_combo.trigcooldown,f))
17970 return qe_invalid;
17971
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12750 times.
12750 if(s_version >= 35)
17972 {
17973
1/2
✓ Branch 0 taken 12750 times.
✗ Branch 1 not taken.
12750 if(!p_igetw(&temp_combo.prompt_cid,f))
17974 return qe_invalid;
17975
1/2
✓ Branch 0 taken 12750 times.
✗ Branch 1 not taken.
12750 if(!p_getc(&temp_combo.prompt_cs,f))
17976 return qe_invalid;
17977
1/2
✓ Branch 0 taken 12750 times.
✗ Branch 1 not taken.
12750 if(!p_igetw(&temp_combo.prompt_x,f))
17978 return qe_invalid;
17979
1/2
✓ Branch 0 taken 12750 times.
✗ Branch 1 not taken.
12750 if(!p_igetw(&temp_combo.prompt_y,f))
17980 return qe_invalid;
17981 12750 }
17982
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 12464 times.
12750 if(s_version >= 36)
17983 {
17984
1/2
✓ Branch 0 taken 12464 times.
✗ Branch 1 not taken.
12464 if(!p_getc(&temp_combo.trig_lstate,f))
17985 return qe_invalid;
17986
1/2
✓ Branch 0 taken 12464 times.
✗ Branch 1 not taken.
12464 if(!p_getc(&temp_combo.trig_gstate,f))
17987 return qe_invalid;
17988
1/2
✓ Branch 0 taken 12464 times.
✗ Branch 1 not taken.
12464 if(!p_igetl(&temp_combo.trig_statetime,f))
17989 return qe_invalid;
17990 12464 }
17991
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 12464 times.
12750 if(s_version >= 37)
17992 {
17993
1/2
✓ Branch 0 taken 12464 times.
✗ Branch 1 not taken.
12464 if(!p_igetw(&temp_combo.trig_genscr,f))
17994 return qe_invalid;
17995 12464 }
17996
2/2
✓ Branch 0 taken 434 times.
✓ Branch 1 taken 12316 times.
12750 if(s_version >= 38)
17997 {
17998
1/2
✓ Branch 0 taken 12316 times.
✗ Branch 1 not taken.
12316 if(!p_getc(&temp_combo.trig_group,f))
17999 return qe_invalid;
18000
1/2
✓ Branch 0 taken 12316 times.
✗ Branch 1 not taken.
12316 if(!p_igetw(&temp_combo.trig_group_val,f))
18001 return qe_invalid;
18002 12316 }
18003
2/2
✓ Branch 0 taken 479 times.
✓ Branch 1 taken 12271 times.
12750 if(s_version >= 45)
18004 {
18005
1/2
✓ Branch 0 taken 12271 times.
✗ Branch 1 not taken.
12271 if(!p_getc(&temp_combo.exdoor_dir,f))
18006 return qe_invalid;
18007
1/2
✓ Branch 0 taken 12271 times.
✗ Branch 1 not taken.
12271 if(!p_getc(&temp_combo.exdoor_ind,f))
18008 return qe_invalid;
18009 12271 }
18010
2/2
✓ Branch 0 taken 8730 times.
✓ Branch 1 taken 4020 times.
12750 if(s_version >= 46)
18011 {
18012
1/2
✓ Branch 0 taken 4020 times.
✗ Branch 1 not taken.
4020 if(!p_getc(&temp_combo.trig_levelitems,f))
18013 return qe_invalid;
18014
1/2
✓ Branch 0 taken 4020 times.
✗ Branch 1 not taken.
4020 if(!p_igetw(&temp_combo.trigdmlevel,f))
18015 return qe_invalid;
18016
2/2
✓ Branch 0 taken 12060 times.
✓ Branch 1 taken 4020 times.
16080 for(int q = 0; q < 3; ++q)
18017
1/2
✓ Branch 0 taken 12060 times.
✗ Branch 1 not taken.
12060 if(!p_getc(&temp_combo.trigtint[q],f))
18018 return qe_invalid;
18019
1/2
✓ Branch 0 taken 4020 times.
✗ Branch 1 not taken.
4020 if(!p_igetw(&temp_combo.triglvlpalette,f))
18020 return qe_invalid;
18021
1/2
✓ Branch 0 taken 4020 times.
✗ Branch 1 not taken.
4020 if(!p_igetw(&temp_combo.trigbosspalette,f))
18022 return qe_invalid;
18023
1/2
✓ Branch 0 taken 4020 times.
✗ Branch 1 not taken.
4020 if(!p_igetw(&temp_combo.trigquaketime,f))
18024 return qe_invalid;
18025
1/2
✓ Branch 0 taken 4020 times.
✗ Branch 1 not taken.
4020 if(!p_igetw(&temp_combo.trigwavytime,f))
18026 return qe_invalid;
18027
1/2
✓ Branch 0 taken 4020 times.
✗ Branch 1 not taken.
4020 if(!p_igetw(&temp_combo.trig_swjinxtime,f))
18028 return qe_invalid;
18029
1/2
✓ Branch 0 taken 4020 times.
✗ Branch 1 not taken.
4020 if(!p_igetw(&temp_combo.trig_itmjinxtime,f))
18030 return qe_invalid;
18031
1/2
✓ Branch 0 taken 4020 times.
✗ Branch 1 not taken.
4020 if(!p_igetw(&temp_combo.trig_stuntime,f))
18032 return qe_invalid;
18033
1/2
✓ Branch 0 taken 4020 times.
✗ Branch 1 not taken.
4020 if(!p_igetw(&temp_combo.trig_bunnytime,f))
18034 return qe_invalid;
18035
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4020 times.
4020 if(!p_getc(&temp_combo.trig_pushtime,f))
18036 return qe_invalid;
18037 4020 }
18038 12750 }
18039
2/2
✓ Branch 0 taken 651197 times.
✓ Branch 1 taken 2015 times.
653212 if(combo_has_flags&CHAS_LIFT)
18040 {
18041
1/2
✓ Branch 0 taken 2015 times.
✗ Branch 1 not taken.
2015 if(!p_igetw(&temp_combo.liftcmb,f))
18042 return qe_invalid;
18043
1/2
✓ Branch 0 taken 2015 times.
✗ Branch 1 not taken.
2015 if(!p_getc(&temp_combo.liftcs,f))
18044 return qe_invalid;
18045
1/2
✓ Branch 0 taken 2015 times.
✗ Branch 1 not taken.
2015 if(!p_igetw(&temp_combo.liftundercmb,f))
18046 return qe_invalid;
18047
1/2
✓ Branch 0 taken 2015 times.
✗ Branch 1 not taken.
2015 if(!p_getc(&temp_combo.liftundercs,f))
18048 return qe_invalid;
18049
1/2
✓ Branch 0 taken 2015 times.
✗ Branch 1 not taken.
2015 if(!p_getc(&temp_combo.liftdmg,f))
18050 return qe_invalid;
18051
1/2
✓ Branch 0 taken 2015 times.
✗ Branch 1 not taken.
2015 if(!p_getc(&temp_combo.liftlvl,f))
18052 return qe_invalid;
18053
1/2
✓ Branch 0 taken 2015 times.
✗ Branch 1 not taken.
2015 if(!p_getc(&temp_combo.liftitm,f))
18054 return qe_invalid;
18055
1/2
✓ Branch 0 taken 2015 times.
✗ Branch 1 not taken.
2015 if(!p_getc(&temp_combo.liftflags,f))
18056 return qe_invalid;
18057
1/2
✓ Branch 0 taken 2015 times.
✗ Branch 1 not taken.
2015 if(!p_getc(&temp_combo.liftgfx,f))
18058 return qe_invalid;
18059
1/2
✓ Branch 0 taken 2015 times.
✗ Branch 1 not taken.
2015 if(!p_getc(&temp_combo.liftsprite,f))
18060 return qe_invalid;
18061
1/2
✓ Branch 0 taken 2015 times.
✗ Branch 1 not taken.
2015 if(!p_getc(&temp_combo.liftsfx,f))
18062 return qe_invalid;
18063
1/2
✓ Branch 0 taken 2015 times.
✗ Branch 1 not taken.
2015 if(!p_igetw(&temp_combo.liftbreaksprite,f))
18064 return qe_invalid;
18065
1/2
✓ Branch 0 taken 2015 times.
✗ Branch 1 not taken.
2015 if(!p_getc(&temp_combo.liftbreaksfx,f))
18066 return qe_invalid;
18067
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2015 times.
2015 if(s_version >= 34)
18068 {
18069
1/2
✓ Branch 0 taken 2015 times.
✗ Branch 1 not taken.
2015 if(!p_getc(&temp_combo.lifthei,f))
18070 return qe_invalid;
18071
1/2
✓ Branch 0 taken 2015 times.
✗ Branch 1 not taken.
2015 if(!p_getc(&temp_combo.lifttime,f))
18072 return qe_invalid;
18073 2015 }
18074
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 2001 times.
2015 if(s_version >= 39)
18075 {
18076
1/2
✓ Branch 0 taken 2001 times.
✗ Branch 1 not taken.
2001 if(!p_getc(&temp_combo.lift_parent_item,f))
18077 return qe_invalid;
18078 2001 }
18079 2015 }
18080
2/2
✓ Branch 0 taken 652145 times.
✓ Branch 1 taken 1067 times.
653212 if(combo_has_flags&CHAS_GENERAL)
18081 {
18082
1/2
✓ Branch 0 taken 1067 times.
✗ Branch 1 not taken.
1067 if(!p_getc(&temp_combo.speed_mult,f))
18083 return qe_invalid;
18084
1/2
✓ Branch 0 taken 1067 times.
✗ Branch 1 not taken.
1067 if(!p_getc(&temp_combo.speed_div,f))
18085 return qe_invalid;
18086
1/2
✓ Branch 0 taken 1067 times.
✗ Branch 1 not taken.
1067 if(!p_igetzf(&temp_combo.speed_add,f))
18087 return qe_invalid;
18088
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1067 times.
1067 if(s_version >= 42)
18089 {
18090
1/2
✓ Branch 0 taken 1067 times.
✗ Branch 1 not taken.
1067 if(!p_getc(&temp_combo.sfx_appear,f))
18091 return qe_invalid;
18092
1/2
✓ Branch 0 taken 1067 times.
✗ Branch 1 not taken.
1067 if(!p_getc(&temp_combo.sfx_disappear,f))
18093 return qe_invalid;
18094
1/2
✓ Branch 0 taken 1067 times.
✗ Branch 1 not taken.
1067 if(!p_getc(&temp_combo.sfx_loop,f))
18095 return qe_invalid;
18096
1/2
✓ Branch 0 taken 1067 times.
✗ Branch 1 not taken.
1067 if(!p_getc(&temp_combo.sfx_walking,f))
18097 return qe_invalid;
18098
1/2
✓ Branch 0 taken 1067 times.
✗ Branch 1 not taken.
1067 if(!p_getc(&temp_combo.sfx_standing,f))
18099 return qe_invalid;
18100
1/2
✓ Branch 0 taken 1067 times.
✗ Branch 1 not taken.
1067 if(!p_getc(&temp_combo.spr_appear,f))
18101 return qe_invalid;
18102
1/2
✓ Branch 0 taken 1067 times.
✗ Branch 1 not taken.
1067 if(!p_getc(&temp_combo.spr_disappear,f))
18103 return qe_invalid;
18104
1/2
✓ Branch 0 taken 1067 times.
✗ Branch 1 not taken.
1067 if(!p_getc(&temp_combo.spr_walking,f))
18105 return qe_invalid;
18106
1/2
✓ Branch 0 taken 1067 times.
✗ Branch 1 not taken.
1067 if(!p_getc(&temp_combo.spr_standing,f))
18107 return qe_invalid;
18108 1067 }
18109
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1067 times.
1067 if(s_version >= 44)
18110 {
18111
1/2
✓ Branch 0 taken 1067 times.
✗ Branch 1 not taken.
1067 if(!p_getc(&temp_combo.sfx_tap,f))
18112 return qe_invalid;
18113 1067 }
18114 1067 }
18115 653212 }
18116 2220488 update_combo(temp_combo, s_version);
18117 2220488 return 0;
18118 2220488 }
18119 589 int32_t readcombos(PACKFILE *f, zquestheader *Header, word version, word build, word start_combo, word max_combos)
18120 {
18121
2/2
✓ Branch 0 taken 565 times.
✓ Branch 1 taken 24 times.
589 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_combos);
18122
18123 589 word section_version=0;
18124 589 word section_cversion=0;
18125 589 word combos_used=0;
18126 int32_t dummy;
18127 byte padding;
18128 589 newcombo temp_combo;
18129
18130
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 588 times.
589 if (!should_skip)
18131 {
18132
1/2
✓ Branch 0 taken 588 times.
✗ Branch 1 not taken.
588 reset_combo_animations();
18133
1/2
✓ Branch 0 taken 588 times.
✗ Branch 1 not taken.
588 reset_combo_animations2();
18134
1/2
✓ Branch 0 taken 588 times.
✗ Branch 1 not taken.
588 init_combo_classes();
18135
18136
2/2
✓ Branch 0 taken 38384640 times.
✓ Branch 1 taken 588 times.
38385228 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
18137
1/2
✓ Branch 0 taken 38384640 times.
✗ Branch 1 not taken.
38384640 combobuf[q].clear();
18138 588 }
18139
18140
2/2
✓ Branch 0 taken 565 times.
✓ Branch 1 taken 24 times.
589 if(version > 0x192) //Version info
18141 {
18142
2/4
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 565 times.
✗ Branch 3 not taken.
565 if(!p_igetw(&section_version,f))
18143 {
18144 return qe_invalid;
18145 }
18146 565 FFCore.quest_format[vCombos] = section_version;
18147
2/4
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 565 times.
✗ Branch 3 not taken.
565 if(!p_igetw(&section_cversion,f))
18148 {
18149 return qe_invalid;
18150 }
18151
18152 //section size
18153
2/4
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 565 times.
✗ Branch 3 not taken.
565 if(!p_igetl(&dummy,f))
18154 {
18155 return qe_invalid;
18156 }
18157 565 }
18158
18159
2/2
✓ Branch 0 taken 389 times.
✓ Branch 1 taken 200 times.
589 if(section_version > 32) //Cleanup time!
18160 {
18161
2/4
✓ Branch 0 taken 389 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 389 times.
✗ Branch 3 not taken.
389 if(!p_igetw(&combos_used,f))
18162 {
18163 return qe_invalid;
18164 }
18165
2/2
✓ Branch 0 taken 2220488 times.
✓ Branch 1 taken 389 times.
2220877 for(int32_t i=0; i<combos_used; i++)
18166 {
18167
1/2
✓ Branch 0 taken 2220488 times.
✗ Branch 1 not taken.
2220488 auto ret = readcombo_loop(f,section_version,temp_combo);
18168
1/2
✓ Branch 0 taken 2220488 times.
✗ Branch 1 not taken.
2220488 if(ret) return ret;
18169
1/2
✓ Branch 0 taken 2220488 times.
✗ Branch 1 not taken.
2220488 if(i>=start_combo)
18170 {
18171
1/2
✓ Branch 0 taken 2220488 times.
✗ Branch 1 not taken.
2220488 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
18172 {
18173 temp_combo.script = 0;
18174 for(int q = 0; q < 8; ++q)
18175 temp_combo.initd[q] = 0;
18176 }
18177
1/2
✓ Branch 0 taken 2220488 times.
✗ Branch 1 not taken.
2220488 combobuf[i] = temp_combo;
18178 2220488 }
18179 2220488 }
18180 389 }
18181 else //Call the old function for all old versions
18182 {
18183
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 auto ret = readcombos_old(section_version,f,Header,version,build,start_combo,max_combos);
18184
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(ret) return ret; //error, end read
18185 }
18186
18187
2/2
✓ Branch 0 taken 588 times.
✓ Branch 1 taken 1 times.
589 if (should_skip)
18188 1 return 0;
18189
18190
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 383 times.
588 if(!get_qr(qr_ALLOW_EDITING_COMBO_0))
18191 {
18192 383 combobuf[0].walk = 0xF0;
18193 383 combobuf[0].type = 0;
18194 383 combobuf[0].flag = 0;
18195 383 }
18196
18197
1/2
✓ Branch 0 taken 588 times.
✗ Branch 1 not taken.
588 setup_combo_animations();
18198
1/2
✓ Branch 0 taken 588 times.
✗ Branch 1 not taken.
588 setup_combo_animations2();
18199 588 return 0;
18200 589 }
18201
18202 526 int32_t readcomboaliases(PACKFILE *f, zquestheader *Header, word version, word build)
18203 {
18204 //these are here to bypass compiler warnings about unused arguments
18205 526 Header=Header;
18206 526 version=version;
18207 526 build=build;
18208
18209 int32_t dummy;
18210 526 word sversion=0, c_sversion;
18211
18212 //section version info
18213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 526 times.
526 if(!p_igetw(&sversion,f))
18214 {
18215 return qe_invalid;
18216 }
18217
18218 526 FFCore.quest_format[vComboAliases] = sversion;
18219
18220 //al_trace("Combo aliases version %d\n", sversion);
18221
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 if(!p_igetw(&c_sversion,f))
18222 {
18223 return qe_invalid;
18224 }
18225
18226 //section size
18227
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 if(!p_igetl(&dummy,f))
18228 {
18229 return qe_invalid;
18230 }
18231
18232 526 int32_t max_num_combo_aliases = MAXCOMBOALIASES;
18233
18234
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 132 times.
526 if(sversion < 3) // max saved combo alias' upped from 256 to 2048.
18235 {
18236 132 max_num_combo_aliases = MAX250COMBOALIASES;
18237 132 }
18238
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 if(sversion < 2) // max saved combo alias' upped from 256 to 2048.
18239 {
18240 max_num_combo_aliases = OLDMAXCOMBOALIASES;
18241 }
18242
18243
2/2
✓ Branch 0 taken 3497984 times.
✓ Branch 1 taken 526 times.
3498510 for(int32_t j=0; j<max_num_combo_aliases; j++)
18244 {
18245 byte width,height,mask,tempcset;
18246 int32_t count;
18247 word tempword;
18248 byte tempbyte;
18249
18250
1/2
✓ Branch 0 taken 3497984 times.
✗ Branch 1 not taken.
3497984 if(!p_igetw(&tempword,f))
18251 {
18252 return qe_invalid;
18253 }
18254
18255 3497984 combo_aliases[j].combo = tempword;
18256
18257
1/2
✓ Branch 0 taken 3497984 times.
✗ Branch 1 not taken.
3497984 if(!p_getc(&tempbyte,f))
18258 {
18259 return qe_invalid;
18260 }
18261
18262 3497984 combo_aliases[j].cset = tempbyte;
18263
18264
1/2
✓ Branch 0 taken 3497984 times.
✗ Branch 1 not taken.
3497984 if(!p_getc(&width,f))
18265 {
18266 return qe_invalid;
18267 }
18268
18269
1/2
✓ Branch 0 taken 3497984 times.
✗ Branch 1 not taken.
3497984 if(!p_getc(&height,f))
18270 {
18271 return qe_invalid;
18272 }
18273
18274
1/2
✓ Branch 0 taken 3497984 times.
✗ Branch 1 not taken.
3497984 if(!p_getc(&mask,f))
18275 {
18276 return qe_invalid;
18277 }
18278
18279 3497984 count=(width+1)*(height+1)*(comboa_lmasktotal(mask)+1);
18280
18281 3497984 combo_aliases[j].width = width;
18282 3497984 combo_aliases[j].height = height;
18283 3497984 combo_aliases[j].layermask = mask;
18284 3497984 combo_aliases[j].combos.clear();
18285 3497984 combo_aliases[j].csets.clear();
18286
18287
2/2
✓ Branch 0 taken 3601518 times.
✓ Branch 1 taken 3497984 times.
7099502 for(int32_t k=0; k<count; k++)
18288 {
18289
1/2
✓ Branch 0 taken 3601518 times.
✗ Branch 1 not taken.
3601518 if(!p_igetw(&tempword,f))
18290 {
18291 return qe_invalid;
18292 }
18293
18294 3601518 combo_aliases[j].combos[k] = tempword;
18295 3601518 }
18296
18297
2/2
✓ Branch 0 taken 3601518 times.
✓ Branch 1 taken 3497984 times.
7099502 for(int32_t k=0; k<count; k++)
18298 {
18299
1/2
✓ Branch 0 taken 3601518 times.
✗ Branch 1 not taken.
3601518 if(!p_getc(&tempcset,f))
18300 {
18301 return qe_invalid;
18302 }
18303
18304 3601518 combo_aliases[j].csets[k] = tempcset;
18305 3601518 }
18306 3497984 }
18307
18308 //Combo pools!
18309 526 word num_combo_pools = 0;
18310
2/2
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 389 times.
526 if(sversion >= 4)
18311 {
18312
1/2
✓ Branch 0 taken 389 times.
✗ Branch 1 not taken.
389 if(!p_igetw(&num_combo_pools,f))
18313 {
18314 return qe_invalid;
18315 }
18316 389 }
18317
18318
2/2
✓ Branch 0 taken 4308992 times.
✓ Branch 1 taken 526 times.
4309518 for(combo_pool& pool : combo_pools)
18319 {
18320 4308992 pool.clear();
18321 }
18322
18323 526 combo_pool temp_cpool;
18324
2/2
✓ Branch 0 taken 1197 times.
✓ Branch 1 taken 526 times.
1723 for(word cp = 0; cp < num_combo_pools; ++cp)
18325 {
18326 1197 int32_t num_combos_in_pool = 0;
18327
2/4
✓ Branch 0 taken 1197 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1197 times.
✗ Branch 3 not taken.
1197 if(!p_igetl(&num_combos_in_pool,f))
18328 {
18329 return qe_invalid;
18330 }
18331
2/2
✓ Branch 0 taken 1125 times.
✓ Branch 1 taken 72 times.
1197 if(num_combos_in_pool < 1) continue; //nothing to read
18332
18333
1/2
✓ Branch 0 taken 1125 times.
✗ Branch 1 not taken.
1125 temp_cpool.clear();
18334
18335 int32_t cp_cid; int8_t cp_cs; word cp_quant;
18336
2/2
✓ Branch 0 taken 1125 times.
✓ Branch 1 taken 4926 times.
6051 for(auto q = 0; q < num_combos_in_pool; ++q)
18337 {
18338
2/4
✓ Branch 0 taken 4926 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4926 times.
✗ Branch 3 not taken.
4926 if(!p_igetl(&cp_cid,f))
18339 {
18340 return qe_invalid;
18341 }
18342
2/4
✓ Branch 0 taken 4926 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4926 times.
✗ Branch 3 not taken.
4926 if(!p_getc(&cp_cs,f))
18343 {
18344 return qe_invalid;
18345 }
18346
2/4
✓ Branch 0 taken 4926 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4926 times.
✗ Branch 3 not taken.
4926 if(!p_igetw(&cp_quant,f))
18347 {
18348 return qe_invalid;
18349 }
18350
1/2
✓ Branch 0 taken 4926 times.
✗ Branch 1 not taken.
4926 temp_cpool.add(cp_cid, cp_cs, cp_quant);
18351 4926 }
18352
18353
1/2
✓ Branch 0 taken 1125 times.
✗ Branch 1 not taken.
1125 combo_pools[cp] = temp_cpool;
18354 1125 }
18355
18356 //Autocombos!
18357 526 word num_combo_autos = 0;
18358
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 150 times.
526 if (sversion >= 5)
18359 {
18360
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if (!p_igetw(&num_combo_autos, f))
18361 {
18362 return qe_invalid;
18363 }
18364 376 }
18365
18366
2/2
✓ Branch 0 taken 526 times.
✓ Branch 1 taken 4308992 times.
4309518 for (combo_auto& cauto : combo_autos)
18367 {
18368
1/2
✓ Branch 0 taken 4308992 times.
✗ Branch 1 not taken.
4308992 cauto.clear(true);
18369 }
18370
18371
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 combo_auto temp_cauto;
18372
2/2
✓ Branch 0 taken 824 times.
✓ Branch 1 taken 526 times.
1350 for (word ca = 0; ca < num_combo_autos; ++ca)
18373 {
18374 byte type;
18375 int32_t display_cid, erase_cid;
18376 byte flags, arg;
18377
2/4
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 824 times.
✗ Branch 3 not taken.
824 if (!p_getc(&type, f))
18378 {
18379 return qe_invalid;
18380 }
18381
2/4
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 824 times.
✗ Branch 3 not taken.
824 if (!p_igetl(&display_cid, f))
18382 {
18383 return qe_invalid;
18384 }
18385
2/4
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 824 times.
✗ Branch 3 not taken.
824 if (!p_igetl(&erase_cid, f))
18386 {
18387 return qe_invalid;
18388 }
18389
2/4
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 824 times.
✗ Branch 3 not taken.
824 if (!p_getc(&flags, f))
18390 {
18391 return qe_invalid;
18392 }
18393
2/4
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 824 times.
✗ Branch 3 not taken.
824 if (!p_getc(&arg, f))
18394 {
18395 return qe_invalid;
18396 }
18397 824 int32_t num_combos_in_cauto = 0;
18398
2/4
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 824 times.
✗ Branch 3 not taken.
824 if (!p_igetl(&num_combos_in_cauto, f))
18399 {
18400 return qe_invalid;
18401 }
18402
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 if (num_combos_in_cauto < 1) continue; //nothing to read
18403
18404
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 temp_cauto.clear();
18405
18406
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 temp_cauto.setType(type);
18407
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 temp_cauto.setDisplay(display_cid);
18408
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 temp_cauto.setEraseCombo(erase_cid);
18409
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 temp_cauto.setFlags(flags);
18410
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 temp_cauto.setArg(arg);
18411
18412 int32_t ca_cid; byte ca_ctype; int16_t ca_offset; int16_t ca_engrave_offset;
18413
2/2
✓ Branch 0 taken 824 times.
✓ Branch 1 taken 10499 times.
11323 for (auto q = 0; q < num_combos_in_cauto; ++q)
18414 {
18415
2/4
✓ Branch 0 taken 10499 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10499 times.
✗ Branch 3 not taken.
10499 if (!p_getc(&ca_ctype, f))
18416 {
18417 return qe_invalid;
18418 }
18419
2/4
✓ Branch 0 taken 10499 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10499 times.
✗ Branch 3 not taken.
10499 if (!p_igetl(&ca_cid, f))
18420 {
18421 return qe_invalid;
18422 }
18423
1/2
✓ Branch 0 taken 10499 times.
✗ Branch 1 not taken.
10499 temp_cauto.addEntry(ca_cid, ca_ctype, q, -1);
18424 10499 }
18425
18426
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 combo_autos[ca] = temp_cauto;
18427 824 }
18428
18429 526 return 0;
18430 526 }
18431
18432 589 int32_t readcolordata(PACKFILE *f, miscQdata *Misc, word version, word build, word start_cset, word max_csets)
18433 {
18434
2/2
✓ Branch 0 taken 565 times.
✓ Branch 1 taken 24 times.
589 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_colors);
18435
18436 //these are here to bypass compiler warnings about unused arguments
18437 //THE *48 REFERS TO EACH CSET BEING 16 COLORS with 3 VALUES OF RGB (3*16 is 48)
18438 //Capitalized cause it'll save you a headache. -Deedee
18439 589 start_cset=start_cset;
18440 589 max_csets=max_csets;
18441 589 word s_version=0;
18442
18443 miscQdata temp_misc;
18444 589 memcpy(&temp_misc, Misc, sizeof(temp_misc));
18445
18446 byte temp_colordata[48];
18447 char temp_palname[PALNAMESIZE+1];
18448
18449 int32_t dummy;
18450 word palcycles;
18451
18452
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 565 times.
589 if(version > 0x192)
18453 {
18454 //section version info
18455
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 if(!p_igetw(&s_version,f))
18456 {
18457 return qe_invalid;
18458 }
18459
18460 565 FFCore.quest_format[vCSets] = s_version;
18461
18462 //al_trace("Color data version %d\n", s_version);
18463
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 if(!p_igetw(&dummy,f))
18464 {
18465 return qe_invalid;
18466 }
18467
18468 //section size
18469
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 if(!p_igetl(&dummy,f))
18470 {
18471 return qe_invalid;
18472 }
18473 565 }
18474
2/2
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 394 times.
589 if (s_version < 5)
18475 {
18476
4/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 177 times.
✓ Branch 2 taken 171 times.
✓ Branch 3 taken 6 times.
195 bool RealOldVerion = ((version < 0x192)||((version == 0x192)&&(build<73)));
18477
18478 //finally... section data
18479 195 int32_t q = 0;
18480 195 int32_t p = -15;
18481
2/2
✓ Branch 0 taken 46800 times.
✓ Branch 1 taken 195 times.
46995 for(int32_t i=0; i<oldpdTOTAL; ++i)
18482 {
18483 46800 memset(temp_colordata, 0, 48);
18484
18485
1/2
✓ Branch 0 taken 46800 times.
✗ Branch 1 not taken.
46800 if(!pfread(temp_colordata,48,f))
18486 {
18487 return qe_invalid;
18488 }
18489
18490
2/2
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 46560 times.
46800 if (should_skip)
18491 240 continue;
18492
18493 46560 memcpy(&colordata[q*48], temp_colordata, 48);
18494
18495 46560 ++q;
18496
8/8
✓ Branch 0 taken 43456 times.
✓ Branch 1 taken 3104 times.
✓ Branch 2 taken 3298 times.
✓ Branch 3 taken 40158 times.
✓ Branch 4 taken 388 times.
✓ Branch 5 taken 2910 times.
✓ Branch 6 taken 36 times.
✓ Branch 7 taken 352 times.
46560 if (p > 0 && (p%13)==12 && (i < oldpoSPRITE || !RealOldVerion)) //It's > 0 instead of >= 0 because it should append
18497 {
18498
1/2
✓ Branch 0 taken 3262 times.
✗ Branch 1 not taken.
3262 if (s_version < 5) //Bumping up the size of level palettes
18499 {
18500 3262 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18501 3262 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18502 3262 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18503 3262 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18504 3262 q+=4;
18505 3262 }
18506 else
18507 {
18508 for(int m = 0; m < 4; ++m)
18509 {
18510 memset(temp_colordata, 0, 48);
18511 if(!pfread(temp_colordata,48,f))
18512 {
18513 return qe_invalid;
18514 }
18515 memcpy(&colordata[q*48], temp_colordata, 48);
18516 ++q;
18517 }
18518 }
18519 3262 }
18520 46560 ++p;
18521 46560 }
18522
18523
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 177 times.
195 if(RealOldVerion)
18524 {
18525
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if (!should_skip)
18526 {
18527 18 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18528 18 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18529 18 memcpy(colordata+((poSPRITE255+11)*48), colordata+((poSPRITE255+10)*48), 48);
18530 18 memcpy(colordata+((poSPRITE255+10)*48), colordata+((poSPRITE255+9)*48), 48);
18531 18 memcpy(colordata+((poSPRITE255+9)*48), colordata+((poSPRITE255+8)*48), 48);
18532 18 memset(colordata+((poSPRITE255+8)*48), 0, 48);
18533 18 }
18534 18 }
18535 else
18536 {
18537 177 memset(temp_colordata, 0, 48);
18538
18539
2/2
✓ Branch 0 taken 554541 times.
✓ Branch 1 taken 177 times.
554718 for(int32_t i=0; i<newpdTOTAL-oldpdTOTAL; ++i)
18540 {
18541
1/2
✓ Branch 0 taken 554541 times.
✗ Branch 1 not taken.
554541 if(!pfread(temp_colordata,48,f))
18542 {
18543 return qe_invalid;
18544 }
18545
18546
2/2
✓ Branch 0 taken 3133 times.
✓ Branch 1 taken 551408 times.
554541 if (should_skip)
18547 3133 continue;
18548
18549 551408 memcpy(&colordata[q*48], temp_colordata, 48);
18550
18551 551408 ++q;
18552
7/8
✓ Branch 0 taken 551408 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 42416 times.
✓ Branch 3 taken 508992 times.
✓ Branch 4 taken 352 times.
✓ Branch 5 taken 42064 times.
✓ Branch 6 taken 264 times.
✓ Branch 7 taken 88 times.
551408 if (p > 0 && (p%13)==12 && (i < (newpoSPRITE-oldpdTOTAL) || (s_version >= 4))) //It's > 0 instead of >= 0 because it should append
18553 {
18554
1/2
✓ Branch 0 taken 42328 times.
✗ Branch 1 not taken.
42328 if (s_version < 5) //Bumping up the size of level palettes
18555 {
18556 42328 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18557 42328 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18558 42328 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18559 42328 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18560 42328 q+=4;
18561 42328 }
18562 else
18563 {
18564 for(int m = 0; m < 4; ++m)
18565 {
18566 memset(temp_colordata, 0, 48);
18567 if(!pfread(temp_colordata,48,f))
18568 {
18569 return qe_invalid;
18570 }
18571 memcpy(&colordata[q*48], temp_colordata, 48);
18572 ++q;
18573 }
18574 }
18575 42328 }
18576 551408 ++p;
18577 551408 }
18578
18579
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 132 times.
177 if(s_version < 4)
18580 {
18581
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 44 times.
45 if (!should_skip)
18582 {
18583 44 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18584 44 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18585 44 }
18586 45 }
18587 else
18588 {
18589
2/2
✓ Branch 0 taken 439296 times.
✓ Branch 1 taken 132 times.
439428 for(int32_t i=0; i<newerpdTOTAL-newpdTOTAL; ++i)
18590 {
18591
1/2
✓ Branch 0 taken 439296 times.
✗ Branch 1 not taken.
439296 if(!pfread(temp_colordata,48,f))
18592 {
18593 return qe_invalid;
18594 }
18595
18596
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 439296 times.
439296 if (should_skip)
18597 continue;
18598
18599 439296 memcpy(&colordata[q*48], temp_colordata, 48);
18600 439296 ++q;
18601
5/6
✓ Branch 0 taken 439296 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 33792 times.
✓ Branch 3 taken 405504 times.
✓ Branch 4 taken 264 times.
✓ Branch 5 taken 33528 times.
439296 if (p > 0 && (p%13)==12 && i < newerpoSPRITE-newpdTOTAL) //It's > 0 instead of >= 0 because it should append
18602 {
18603
1/2
✓ Branch 0 taken 33528 times.
✗ Branch 1 not taken.
33528 if (s_version < 5) //Bumping up the size of level palettes
18604 {
18605 33528 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18606 33528 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18607 33528 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18608 33528 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18609 33528 q+=4;
18610 33528 }
18611 else
18612 {
18613 for(int m = 0; m < 4; ++m)
18614 {
18615 memset(temp_colordata, 0, 48);
18616 if(!pfread(temp_colordata,48,f))
18617 {
18618 return qe_invalid;
18619 }
18620 memcpy(&colordata[q*48], temp_colordata, 48);
18621 ++q;
18622 }
18623 }
18624 33528 }
18625 439296 ++p;
18626 439296 }
18627
18628 //By this point, q should be about equal to pdTOTAL255. If it isn't, I've fucked up. -Deedee
18629 }
18630 }
18631 195 }
18632 else
18633 {
18634
2/2
✓ Branch 0 taken 3447106 times.
✓ Branch 1 taken 394 times.
3447500 for(int32_t i=0; i<pdTOTAL255; ++i)
18635 {
18636 3447106 memset(temp_colordata, 0, 48);
18637
18638
1/2
✓ Branch 0 taken 3447106 times.
✗ Branch 1 not taken.
3447106 if(!pfread(temp_colordata,48,f))
18639 {
18640 return qe_invalid;
18641 }
18642
18643 3447106 memcpy(&colordata[i*48], temp_colordata, 48);
18644 3447106 }
18645 }
18646
18647
5/6
✓ Branch 0 taken 571 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 565 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
589 if((version < 0x192)||((version == 0x192)&&(build<76)))
18648 {
18649
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if (!should_skip)
18650 18 init_palnames();
18651 18 }
18652 else
18653 {
18654 571 int32_t palnamestoread = 0;
18655
18656
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 526 times.
571 if(s_version < 3)
18657 45 palnamestoread = OLDMAXLEVELS;
18658 else
18659 526 palnamestoread = 512;
18660
18661
2/2
✓ Branch 0 taken 280832 times.
✓ Branch 1 taken 571 times.
281403 for(int32_t i=0; i<palnamestoread; ++i)
18662 {
18663
1/2
✓ Branch 0 taken 280832 times.
✗ Branch 1 not taken.
280832 if(!p_getstr(temp_palname,PALNAMESIZE,f))
18664 {
18665 return qe_invalid;
18666 }
18667
18668
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 280576 times.
280832 if (!should_skip)
18669 280576 memcpy(palnames[i], temp_palname, PALNAMESIZE);
18670 280832 }
18671
18672
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 570 times.
571 if (should_skip)
18673 1 return 0;
18674
18675
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 570 times.
11834 for(int32_t i=palnamestoread; i<MAXLEVELS; i++)
18676 {
18677 11264 memset(palnames[i], 0, PALNAMESIZE);
18678 11264 }
18679 }
18680
18681
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 565 times.
588 if(version > 0x192)
18682 {
18683
2/2
✓ Branch 0 taken 144640 times.
✓ Branch 1 taken 565 times.
145205 for(int32_t i=0; i<256; i++)
18684 {
18685
2/2
✓ Branch 0 taken 433920 times.
✓ Branch 1 taken 144640 times.
578560 for(int32_t j=0; j<3; j++)
18686 {
18687 433920 temp_misc.cycles[i][j].first=0;
18688 433920 temp_misc.cycles[i][j].count=0;
18689 433920 temp_misc.cycles[i][j].speed=0;
18690 433920 }
18691 144640 }
18692
18693
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 if(!p_igetw(&palcycles,f))
18694 {
18695 return qe_invalid;
18696 }
18697
18698
2/4
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 565 times.
565 if (!(palcycles >= 0 && palcycles <= NUM_PAL_CYCLES))
18699 {
18700 return qe_invalid;
18701 }
18702
18703
2/2
✓ Branch 0 taken 9314 times.
✓ Branch 1 taken 565 times.
9879 for(int32_t i=0; i<palcycles; i++)
18704 {
18705
2/2
✓ Branch 0 taken 27942 times.
✓ Branch 1 taken 9314 times.
37256 for(int32_t j=0; j<3; j++)
18706 {
18707
1/2
✓ Branch 0 taken 27942 times.
✗ Branch 1 not taken.
27942 if(!p_getc(&temp_misc.cycles[i][j].first,f))
18708 {
18709 return qe_invalid;
18710 }
18711 27942 }
18712
18713
2/2
✓ Branch 0 taken 27942 times.
✓ Branch 1 taken 9314 times.
37256 for(int32_t j=0; j<3; j++)
18714 {
18715
1/2
✓ Branch 0 taken 27942 times.
✗ Branch 1 not taken.
27942 if(!p_getc(&temp_misc.cycles[i][j].count,f))
18716 {
18717 return qe_invalid;
18718 }
18719 27942 }
18720
18721
2/2
✓ Branch 0 taken 27942 times.
✓ Branch 1 taken 9314 times.
37256 for(int32_t j=0; j<3; j++)
18722 {
18723
1/2
✓ Branch 0 taken 27942 times.
✗ Branch 1 not taken.
27942 if(!p_getc(&temp_misc.cycles[i][j].speed,f))
18724 {
18725 return qe_invalid;
18726 }
18727 27942 }
18728 9314 }
18729
18730 565 memcpy(Misc, &temp_misc, sizeof(temp_misc));
18731 565 }
18732
18733 588 return 0;
18734 589 }
18735
18736 589 int32_t readtiles(PACKFILE *f, tiledata *buf, zquestheader *Header, word version, word build, word start_tile, int32_t max_tiles, bool from_init)
18737 {
18738
2/2
✓ Branch 0 taken 565 times.
✓ Branch 1 taken 24 times.
589 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_tiles);
18739
18740 589 int32_t tiles_used=0;
18741 589 word section_version = 0;
18742 589 word section_cversion = 0;
18743 589 int32_t section_size= 0;
18744 589 byte *temp_tile = new byte[tilesize(tf32Bit)];
18745
18746 //Tile Expansion
18747 //if ( version >= 0x254 && build >= 41 )
18748
4/4
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 394 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 189 times.
589 if (version < 0x254 && build < 41)
18749 {
18750 //al_trace("Build was < 41 when reading tiles\n");
18751 189 max_tiles = ZC250MAXTILES;
18752 189 }
18753
18754 //al_trace("Max Tiles: %d\n", max_tiles);
18755
18756
2/6
✓ Branch 0 taken 589 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 589 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
589 if(Header!=NULL&&(!Header->data_flags[ZQ_TILES]&&!from_init)) //keep for old quests
18757 {
18758 if(!init_tiles(true, Header))
18759 {
18760 al_trace("Unable to initialize tiles\n");
18761 }
18762
18763 delete[] temp_tile;
18764 temp_tile=NULL;
18765 return 0;
18766 }
18767 else
18768 {
18769
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 565 times.
589 if(version > 0x192)
18770 {
18771 //section version info
18772
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 if(!p_igetw(&section_version,f))
18773 {
18774 delete[] temp_tile;
18775 return qe_invalid;
18776 }
18777
18778 565 FFCore.quest_format[vTiles] = section_version;
18779
18780
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 if(!p_igetw(&section_cversion,f))
18781 {
18782 delete[] temp_tile;
18783 return qe_invalid;
18784 }
18785
18786 //section size
18787
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 if(!p_igetl(&section_size,f))
18788 {
18789 delete[] temp_tile;
18790 return qe_invalid;
18791 }
18792 565 }
18793
18794 //if ( build < 41 )
18795 //{
18796 // tiles_used = ZC250MAXTILES;
18797 //}
18798
18799
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 589 times.
589 if(version < 0x174)
18800 {
18801 tiles_used=TILES_PER_PAGE*4;
18802 } //no expanded tile space
18803
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 571 times.
589 else if(version < 0x191)
18804 {
18805 18 tiles_used=OLDMAXTILES;
18806 18 }
18807 else
18808 {
18809 //finally... section data
18810
3/4
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 177 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 394 times.
571 if ( version >= 0x254 && build >= 41 ) //read and write the size of tiles_used properly
18811 {
18812
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if(!p_igetl(&tiles_used,f))
18813 {
18814 delete[] temp_tile;
18815 return qe_invalid;
18816 }
18817 394 }
18818 else
18819 {
18820
1/2
✓ Branch 0 taken 177 times.
✗ Branch 1 not taken.
177 if(!p_igetw(&tiles_used,f))
18821 {
18822 delete[] temp_tile;
18823 return qe_invalid;
18824 }
18825 }
18826 }
18827
18828
1/2
✓ Branch 0 taken 589 times.
✗ Branch 1 not taken.
589 tiles_used=zc_min(tiles_used, max_tiles);
18829
18830 //if ( version < 0x254 || ( version >= 0x254 && build < 41 )) //don't do this, it crashes ZQuest. -Z
18831 //if ( version < 0x254 && build < 41 )
18832
3/6
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 195 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 394 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
589 if ( version < 0x254 || (version == 0x254 && build < 41) )
18833 //if ( build < 41 )
18834 {
18835
1/2
✓ Branch 0 taken 195 times.
✗ Branch 1 not taken.
195 tiles_used=zc_min(tiles_used, ZC250MAXTILES-start_tile);
18836 195 }
18837 else //2.55
18838 {
18839
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 tiles_used = zc_min(tiles_used,NEWMAXTILES-start_tile);
18840 }
18841
18842 //if ( section_version > 1 ) tiles_used = NEWMAXTILES;
18843
18844 //al_trace("tiles_used = %d\n", tiles_used);
18845
18846
2/2
✓ Branch 0 taken 23028662 times.
✓ Branch 1 taken 589 times.
23029251 for(int32_t i=0; i<tiles_used; ++i)
18847 {
18848 23028662 byte format=tf4Bit;
18849 23028662 memset(temp_tile, 0, tilesize(tf32Bit));
18850
18851
3/6
✓ Branch 0 taken 1944176 times.
✓ Branch 1 taken 21084486 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1944176 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
23028662 if((version>0x211)||((version==0x211)&&(build>4)))
18852 {
18853
1/2
✓ Branch 0 taken 21084486 times.
✗ Branch 1 not taken.
21084486 if(!p_getc(&format,f))
18854 {
18855 delete[] temp_tile;
18856 return qe_invalid;
18857 }
18858 21084486 }
18859
4/4
✓ Branch 0 taken 16822185 times.
✓ Branch 1 taken 6206477 times.
✓ Branch 2 taken 7745487 times.
✓ Branch 3 taken 9076698 times.
23028662 if(section_version > 2 && !format)
18860 {
18861 9076698 reset_tile(buf,start_tile+i,tf4Bit);
18862 9076698 continue;
18863 }
18864
18865
2/2
✓ Branch 0 taken 13638541 times.
✓ Branch 1 taken 313423 times.
13951964 int size = format == tf4Bit ? 128 : tilesize(format);
18866
1/2
✓ Branch 0 taken 13951964 times.
✗ Branch 1 not taken.
13951964 if(!pfread(temp_tile,size,f))
18867 {
18868 delete[] temp_tile;
18869 return qe_invalid;
18870 }
18871
18872
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13951964 times.
13951964 if (should_skip)
18873 continue;
18874
18875 13951964 buf[start_tile+i].format=format;
18876
18877
2/2
✓ Branch 0 taken 13833296 times.
✓ Branch 1 taken 118668 times.
13951964 if(buf[start_tile+i].data)
18878 {
18879 13833296 free(buf[start_tile+i].data);
18880 13833296 buf[start_tile+i].data=NULL;
18881 13833296 }
18882
18883 13951964 buf[start_tile+i].data=(byte *)malloc(tilesize(buf[start_tile+i].format));
18884
18885
2/2
✓ Branch 0 taken 13638541 times.
✓ Branch 1 taken 313423 times.
13951964 if (format == tf4Bit)
18886 {
18887 byte temp[256];
18888 13638541 byte *si = temp_tile + 128;
18889 13638541 byte *di = temp + 256;
18890
18891
2/2
✓ Branch 0 taken 1745733248 times.
✓ Branch 1 taken 13638541 times.
1759371789 for(int i=127; i>=0; --i)
18892 {
18893 1745733248 (*(--di)) = (*(--si)) >> 4;
18894 1745733248 (*(--di)) = (*si) & 15;
18895 1745733248 }
18896
18897 13638541 memcpy(buf[start_tile+i].data,temp,256);
18898 13638541 }
18899 else
18900 {
18901 313423 memcpy(buf[start_tile+i].data,temp_tile,tilesize(buf[start_tile+i].format));
18902 }
18903 13951964 }
18904 }
18905
18906
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 589 times.
589 if (should_skip)
18907 return 0;
18908
18909
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 195 times.
589 if ( section_version < 2 ) //write blank tile data --check s_version with this again instead?
18910 {
18911 //al_trace("Writing blank tile data to new tiles for build < 41\n");
18912
2/2
✓ Branch 0 taken 29051100 times.
✓ Branch 1 taken 195 times.
29051295 for ( int32_t q = ZC250MAXTILES; q < NEWMAXTILES; ++q )
18913 {
18914
18915 //memcpy(buf[q].data,temp_tile,tilesize(buf[q].format));
18916 29051100 reset_tile(buf,q,tf4Bit);
18917
18918
18919 /*
18920
18921 byte tempbyte;
18922 for(int32_t i=0; i<tilesize(tf4Bit); i++)
18923 {
18924 tempbyte=buf[ZC250MAXTILES-1].data[i];
18925 buf[q].data[i] = tempbyte;
18926 }
18927 //int32_t temp = tempbyte=buf[130].data[i];
18928 //buf[q].data = buf[ZC250MAXTILES-1].data;
18929 */
18930 //reset_tile(buf,q,tf4Bit);
18931 29051100 }
18932
18933 195 }
18934
18935
4/6
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 195 times.
✓ Branch 2 taken 394 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 394 times.
589 if ( version < 0x254 || ( version >= 0x254 && build < 41 ))
18936 {
18937
2/2
✓ Branch 0 taken 8037519 times.
✓ Branch 1 taken 195 times.
8037714 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
18938 {
18939 //al_trace("Resetting tiles for ZC250MAXTILES, iteration: %d\n", i);
18940 8037519 reset_tile(buf,i,tf4Bit);
18941 8037519 }
18942 195 }
18943 else
18944 {
18945
2/2
✓ Branch 0 taken 67117099 times.
✓ Branch 1 taken 394 times.
67117493 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
18946 {
18947 //al_trace("Resetting tiles for build 41+\n");
18948 67117099 reset_tile(buf,i,tf4Bit);
18949 67117099 }
18950 }
18951
18952
5/6
✓ Branch 0 taken 571 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 565 times.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
589 if((version < 0x192)|| ((version == 0x192)&&(build<186)))
18953 {
18954
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 6 times.
24 if(get_qr(qr_BSZELDA)) //
18955 {
18956 byte tempbyte;
18957 6 int32_t floattile=wpnsbuf[iwSwim].tile;
18958
18959
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 6 times.
1542 for(int32_t i=0; i<tilesize(tf4Bit); i++) //BSZelda tiles are out of order //does this include swim tiles?
18960 {
18961 1536 tempbyte=buf[23].data[i];
18962 1536 buf[23].data[i]=buf[24].data[i];
18963 1536 buf[24].data[i]=buf[25].data[i];
18964 1536 buf[25].data[i]=buf[26].data[i];
18965 1536 buf[26].data[i]=tempbyte;
18966 1536 }
18967 //swim tiles are out of order, too, but nobody cared? -Z
18968
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 6 times.
1542 for(int32_t i=0; i<tilesize(tf4Bit); i++)
18969 {
18970 1536 tempbyte=buf[floattile+11].data[i];
18971 1536 buf[floattile+11].data[i]=buf[floattile+12].data[i];
18972 1536 buf[floattile+12].data[i]=tempbyte;
18973 1536 }
18974 6 }
18975 24 }
18976
18977
3/6
✓ Branch 0 taken 526 times.
✓ Branch 1 taken 63 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 526 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
589 if((version < 0x211)||((version == 0x211)&&(build<7))) //Goriya tiles are out of order
18978 {
18979
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 22 times.
63 if(!get_qr(qr_NEWENEMYTILES))
18980 {
18981 byte tempbyte;
18982
18983
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 22 times.
5654 for(int32_t i=0; i<tilesize(tf4Bit); i++)
18984 {
18985 5632 tempbyte=buf[130].data[i];
18986 5632 buf[130].data[i]=buf[132].data[i];
18987 5632 buf[132].data[i]=tempbyte;
18988
18989 5632 tempbyte=buf[131].data[i];
18990 5632 buf[131].data[i]=buf[133].data[i];
18991 5632 buf[133].data[i]=tempbyte;
18992 5632 }
18993 22 }
18994 63 }
18995
18996 589 al_trace("Registering blank tiles\n");
18997 589 register_blank_tiles();
18998
18999 //memset(temp_tile, 0, tilesize(tf32Bit));
19000
1/2
✓ Branch 0 taken 589 times.
✗ Branch 1 not taken.
589 delete[] temp_tile;
19001 589 temp_tile=NULL;
19002 589 return 0;
19003 589 }
19004
19005 588 int32_t readtunes(PACKFILE *f, zquestheader *Header, zctune *tunes /*zcmidi_ *midis*/)
19006 {
19007
2/2
✓ Branch 0 taken 565 times.
✓ Branch 1 taken 23 times.
588 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_midis);
19008
19009 static byte fake_midi_flags[32];
19010
19011
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 588 times.
588 byte *mf=should_skip ? fake_midi_flags : midi_flags;
19012 int32_t dummy;
19013 word dummy2;
19014 // zcmidi_ temp_midi;
19015 int32_t tunes_to_read;
19016 588 int32_t tune_count=0;
19017 588 word section_version=0;
19018 588 zctune temp;
19019
19020
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 565 times.
588 if(Header->zelda_version < 0x193)
19021 {
19022 // mf=Header->data_flags+ZQ_MIDIS2;
19023
5/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 1 times.
23 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<178)))
19024 {
19025 22 tunes_to_read=MAXCUSTOMMIDIS192b177;
19026 22 }
19027 else
19028 {
19029 1 tunes_to_read=MAXCUSTOMTUNES;
19030 }
19031 23 }
19032 else
19033 {
19034 //section version info
19035
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 if(!p_igetw(&section_version,f))
19036 {
19037 return qe_invalid;
19038 }
19039
19040
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 565 times.
565 if (!should_skip)
19041 565 FFCore.quest_format[vMIDIs] = section_version;
19042
19043 //al_trace("Tunes version %d\n", section_version);
19044
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 if(!p_igetw(&dummy2,f))
19045 {
19046 return qe_invalid;
19047 }
19048
19049 //section size
19050
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 if(!p_igetl(&dummy,f))
19051 {
19052 return qe_invalid;
19053 }
19054
19055 //finally... section data
19056
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 if(!pfread(midi_flags,sizeof(midi_flags),f))
19057 {
19058 return qe_invalid;
19059 }
19060
19061 565 tunes_to_read=MAXCUSTOMTUNES;
19062 }
19063
19064
2/2
✓ Branch 0 taken 148176 times.
✓ Branch 1 taken 588 times.
148764 for(int32_t i=0; i<MAXCUSTOMTUNES; ++i)
19065 {
19066
2/2
✓ Branch 0 taken 6327 times.
✓ Branch 1 taken 141849 times.
148176 if(get_bit(mf, i))
19067 {
19068 6327 ++tune_count;
19069 6327 }
19070 148176 }
19071
19072
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 588 times.
588 if (!should_skip)
19073 588 reset_tunes(tunes); //reset_midis(midis);
19074
19075
2/2
✓ Branch 0 taken 143336 times.
✓ Branch 1 taken 588 times.
143924 for(int32_t i=0; i<tunes_to_read; i++)
19076 {
19077 143336 temp.clear(); //memset(&temp_midi,0,sizeof(zcmidi_));
19078
19079
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 143336 times.
143336 if (!should_skip)
19080 143336 tunes[i].reset(); // reset_midi(midis+i);
19081
19082
2/2
✓ Branch 0 taken 137009 times.
✓ Branch 1 taken 6327 times.
143336 if(get_bit(mf,i))
19083 {
19084
2/2
✓ Branch 0 taken 1865 times.
✓ Branch 1 taken 4462 times.
6327 if(section_version < 4)
19085 {
19086
1/2
✓ Branch 0 taken 1865 times.
✗ Branch 1 not taken.
1865 if(!p_getstr(temp.title,20,f))
19087 {
19088 return qe_invalid;
19089 }
19090 1865 }
19091 else
19092 {
19093
1/2
✓ Branch 0 taken 4462 times.
✗ Branch 1 not taken.
4462 if(!p_getstr(temp.title,sizeof(temp.title)-1,f))
19094 {
19095 return qe_invalid;
19096 }
19097 }
19098
19099
1/2
✓ Branch 0 taken 6327 times.
✗ Branch 1 not taken.
6327 if(!p_igetl(&temp.start,f))
19100 {
19101 return qe_invalid;
19102 }
19103
19104
1/2
✓ Branch 0 taken 6327 times.
✗ Branch 1 not taken.
6327 if(!p_igetl(&temp.loop_start,f))
19105 {
19106 return qe_invalid;
19107 }
19108
19109
1/2
✓ Branch 0 taken 6327 times.
✗ Branch 1 not taken.
6327 if(!p_igetl(&temp.loop_end,f))
19110 {
19111 return qe_invalid;
19112 }
19113
19114
1/2
✓ Branch 0 taken 6327 times.
✗ Branch 1 not taken.
6327 if(!p_igetw(&temp.loop,f))
19115 {
19116 return qe_invalid;
19117 }
19118
19119
1/2
✓ Branch 0 taken 6327 times.
✗ Branch 1 not taken.
6327 if(!p_igetw(&temp.volume,f))
19120 {
19121 return qe_invalid;
19122 }
19123
19124
2/2
✓ Branch 0 taken 6078 times.
✓ Branch 1 taken 249 times.
6327 if(Header->zelda_version < 0x193)
19125 {
19126
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if(!p_igetl(&dummy,f))
19127 {
19128 return qe_invalid;
19129 }
19130 249 }
19131
19132
2/2
✓ Branch 0 taken 1865 times.
✓ Branch 1 taken 4462 times.
6327 if(section_version >= 3)
19133 {
19134
1/2
✓ Branch 0 taken 4462 times.
✗ Branch 1 not taken.
4462 if(!pfread(&temp.flags,sizeof(temp.flags),f))
19135 {
19136 return qe_invalid;
19137 }
19138 4462 }
19139
19140
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6327 times.
6327 if (!should_skip)
19141 6327 tunes[i].copyfrom(temp); // memcpy(&midis[i], &temp_midi, sizeof(zcmidi_));
19142
19143
2/2
✓ Branch 0 taken 1865 times.
✓ Branch 1 taken 4462 times.
6327 if(section_version < 2) //= 1 || (Header->zelda_version < 0x211) || (Header->zelda_version == 0x211 && Header->build < 18))
19144 {
19145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1865 times.
1865 if (should_skip)
19146 {
19147 if (read_midi(f)==NULL)
19148 {
19149 return qe_invalid;
19150 }
19151
19152 continue;
19153 }
19154
19155 // old format - a midi is a midi
19156
1/2
✓ Branch 0 taken 1865 times.
✗ Branch 1 not taken.
1865 if((tunes[i].data=read_midi(f))==NULL)
19157 {
19158 return qe_invalid;
19159 }
19160
19161 //yes you can do this. Isn't the ? operator awesome? :)
19162 1865 tunes[i].format = MFORMAT_MIDI;
19163 1865 }
19164 else
19165 {
19166 // 'midi' could be midi or nes, gb, ... music
19167
1/2
✓ Branch 0 taken 4462 times.
✗ Branch 1 not taken.
4462 if(!pfread(&tunes[i].format,sizeof(tunes[i].format),f))
19168 {
19169 return qe_invalid;
19170 }
19171
19172 4462 zctune *ptr = &tunes[i];
19173
19174
1/2
✓ Branch 0 taken 4462 times.
✗ Branch 1 not taken.
4462 switch(temp.format)
19175 {
19176 case MFORMAT_MIDI:
19177
1/2
✓ Branch 0 taken 4462 times.
✗ Branch 1 not taken.
4462 if((ptr->data=read_midi(f))==NULL)
19178 {
19179 return qe_invalid;
19180 }
19181
19182 4462 break;
19183
19184 default:
19185 return qe_invalid;
19186 break;
19187 }
19188 }
19189 6327 }
19190 143336 }
19191
19192 588 return 0;
19193 588 }
19194
19195 588 int32_t readcheatcodes(PACKFILE *f, zquestheader *Header)
19196 {
19197
2/2
✓ Branch 0 taken 565 times.
✓ Branch 1 taken 23 times.
588 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_cheats);
19198
19199 int32_t dummy;
19200 ZCHEATS tempzcheats;
19201 588 char temp_use_cheats=1;
19202 588 memset(&tempzcheats, 0, sizeof(tempzcheats));
19203 588 word s_version = 0;
19204
19205
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 565 times.
588 if(Header->zelda_version > 0x192)
19206 {
19207 //section version info
19208
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 if(!p_igetw(&s_version,f))
19209 {
19210 return qe_invalid;
19211 }
19212
19213 565 FFCore.quest_format[vCheats] = s_version;
19214 //al_trace("Cheats version %d\n", dummy);
19215
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 if(!p_igetw(&dummy,f))
19216 {
19217 return qe_invalid;
19218 }
19219
19220 //section size
19221
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 if(!p_igetl(&dummy,f))
19222 {
19223 return qe_invalid;
19224 }
19225
19226 //finally... section data
19227
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 565 times.
565 if(!p_getc(&temp_use_cheats,f))
19228 {
19229 return qe_invalid;
19230 }
19231 565 }
19232
19233
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 588 times.
588 if(Header->data_flags[ZQ_CHEATS2])
19234 {
19235
1/2
✓ Branch 0 taken 588 times.
✗ Branch 1 not taken.
588 if(!p_igetl(&tempzcheats.flags,f))
19236 {
19237 return qe_invalid;
19238 }
19239
19240
1/2
✓ Branch 0 taken 588 times.
✗ Branch 1 not taken.
588 if(!pfread(&tempzcheats.codes, sizeof(tempzcheats.codes),f))
19241 {
19242 return qe_invalid;
19243 }
19244 588 }
19245
19246
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 588 times.
588 if (should_skip)
19247 return 0;
19248
19249 588 memcpy(&zcheats, &tempzcheats, sizeof(tempzcheats));
19250 588 Header->data_flags[ZQ_CHEATS2]=temp_use_cheats;
19251
19252 588 return 0;
19253 588 }
19254
19255 212 int32_t readinitdata_old(PACKFILE *f, zquestheader *Header, word s_version, word s_cversion, zinitdata& temp_zinit)
19256 {
19257
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 189 times.
212 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_initdata);
19258
19259 int32_t dummy;
19260 byte padding, tempbyte;
19261
19262 // Legacy item properties (now integrated into itemdata)
19263 byte sword_hearts[4];
19264 byte beam_hearts[4];
19265 212 byte beam_percent=0;
19266 word beam_power[4];
19267 212 byte hookshot_length=99;
19268 212 byte hookshot_links=100;
19269 212 byte longshot_length=99;
19270 212 byte longshot_links=100;
19271 212 byte moving_fairy_hearts=3;
19272 212 byte moving_fairy_heart_percent=0;
19273 212 byte stationary_fairy_hearts=3;
19274 212 byte stationary_fairy_heart_percent=0;
19275 212 byte moving_fairy_magic=0;
19276 212 byte moving_fairy_magic_percent=0;
19277 212 byte stationary_fairy_magic=0;
19278 212 byte stationary_fairy_magic_percent=0;
19279 212 byte blue_potion_hearts=100;
19280 212 byte blue_potion_heart_percent=1;
19281 212 byte red_potion_hearts=100;
19282 212 byte red_potion_heart_percent=1;
19283 212 byte blue_potion_magic=100;
19284 212 byte blue_potion_magic_percent=1;
19285 212 byte red_potion_magic=100;
19286 212 byte red_potion_magic_percent=1;
19287
19288 212 byte bomb_ratio = 4;
19289
19290 212 subscr_mode = 0;
19291
19292 /* HIGHLY UNORTHODOX UPDATING THING, by L
19293 * This fixes quests made before revision 277 (such as the 'Lost Isle Build'),
19294 * where the speed of Pols Voice changed. It also coincided with V_INITDATA
19295 * changing from 13 to 14.
19296 */
19297
2/2
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 62 times.
212 if(s_version < 14)
19298 62 fixpolsvoice=true;
19299
19300 /* End highly unorthodox updating thing */
19301
19302
4/4
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 62 times.
✓ Branch 2 taken 89 times.
✓ Branch 3 taken 61 times.
212 if(s_version >= 15 && get_bit(deprecated_rules, 27)) // The int16_t-lived rule, qr_JUMPHEROLAYER3
19303 61 temp_zinit.jump_hero_layer_threshold=0;
19304
19305
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 150 times.
212 if(s_version >= 10)
19306 {
19307 char temp;
19308
19309 //new-style items
19310
2/2
✓ Branch 0 taken 38400 times.
✓ Branch 1 taken 150 times.
38550 for(int32_t j=0; j<256; j++)
19311 {
19312
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38400 times.
38400 if(!p_getc(&temp,f))
19313 return qe_invalid;
19314
19315 38400 temp_zinit.set_item(j, temp != 0);
19316 38400 }
19317 150 }
19318
19319
5/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 189 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 18 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
212 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>26)))
19320 {
19321 char temp;
19322
19323 //finally... section data
19324
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 189 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
199 if((Header->zelda_version > 0x192)||
19325 //new only
19326
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19327 {
19328 //OLD-style items... sigh
19329
2/2
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 40 times.
190 if(s_version < 10)
19330 {
19331
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(!p_getc(&temp,f))
19332 {
19333 return qe_invalid;
19334 }
19335
19336 40 temp_zinit.set_item(iRaft, temp != 0);
19337
19338
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(!p_getc(&temp,f))
19339 {
19340 return qe_invalid;
19341 }
19342
19343 40 temp_zinit.set_item(iLadder, temp != 0);
19344
19345
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(!p_getc(&temp,f))
19346 {
19347 return qe_invalid;
19348 }
19349
19350 40 temp_zinit.set_item(iBook, temp != 0);
19351
19352
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(!p_getc(&temp,f))
19353 {
19354 return qe_invalid;
19355 }
19356
19357 40 temp_zinit.set_item(iMKey, temp != 0);
19358
19359
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(!p_getc(&temp,f))
19360 {
19361 return qe_invalid;
19362 }
19363
19364 40 temp_zinit.set_item(iFlippers, temp != 0);
19365
19366
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(!p_getc(&temp,f))
19367 {
19368 return qe_invalid;
19369 }
19370
19371 40 temp_zinit.set_item(iBoots, temp != 0);
19372 40 }
19373 190 }
19374
19375
2/2
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 44 times.
194 if(s_version < 10)
19376 {
19377 char tempring, tempsword, tempshield, tempwallet, tempbracelet, tempamulet, tempbow;
19378
19379
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if(!p_getc(&tempring,f))
19380 {
19381 return qe_invalid;
19382 }
19383
19384
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if(!p_getc(&tempsword,f))
19385 {
19386 return qe_invalid;
19387 }
19388
19389
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if(!p_getc(&tempshield,f))
19390 {
19391 return qe_invalid;
19392 }
19393
19394
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if(!p_getc(&tempwallet,f))
19395 {
19396 return qe_invalid;
19397 }
19398
19399
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if(!p_getc(&tempbracelet,f))
19400 {
19401 return qe_invalid;
19402 }
19403
19404
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if(!p_getc(&tempamulet,f))
19405 {
19406 return qe_invalid;
19407 }
19408
19409
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if(!p_getc(&tempbow,f))
19410 {
19411 return qe_invalid;
19412 }
19413
19414 //old only
19415
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
44 if((Header->zelda_version == 0x192)&&(Header->build<174))
19416 {
19417
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempring=(tempring)?(1<<(tempring-1)):0;
19418
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempsword=(tempsword)?(1<<(tempsword-1)):0;
19419
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 tempshield=(tempshield)?(1<<(tempshield-1)):0;
19420
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempwallet=(tempwallet)?(1<<(tempwallet-1)):0;
19421
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempbracelet=(tempbracelet)?(1<<(tempbracelet-1)):0;
19422
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempamulet=(tempamulet)?(1<<(tempamulet-1)):0;
19423
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempbow=(tempbow)?(1<<(tempbow-1)):0;
19424 4 }
19425
19426 //rings start at level 2... wtf
19427 //account for this -DD
19428 44 tempring <<= 1;
19429 44 addOldStyleFamily(&temp_zinit, itemsbuf, itype_ring, tempring);
19430 44 addOldStyleFamily(&temp_zinit, itemsbuf, itype_sword, tempsword);
19431 44 addOldStyleFamily(&temp_zinit, itemsbuf, itype_shield, tempshield);
19432 44 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, tempwallet);
19433 //bracelet ALSO starts at level 2 :-( -DD
19434 44 tempbracelet<<=1;
19435 44 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bracelet, tempbracelet);
19436 44 addOldStyleFamily(&temp_zinit, itemsbuf, itype_amulet, tempamulet);
19437 44 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bow, tempbow);
19438
19439 //new only
19440
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1 times.
44 if((Header->zelda_version == 0x192)&&(Header->build>173))
19441 {
19442
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 1 times.
33 for(int32_t q=0; q<32; q++)
19443 {
19444
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(!p_getc(&padding,f))
19445 {
19446 return qe_invalid;
19447 }
19448 32 }
19449 1 }
19450
19451 char tempcandle, tempboomerang, temparrow, tempwhistle;
19452
19453
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if(!p_getc(&tempcandle,f))
19454 {
19455 return qe_invalid;
19456 }
19457
19458
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if(!p_getc(&tempboomerang,f))
19459 {
19460 return qe_invalid;
19461 }
19462
19463
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if(!p_getc(&temparrow,f))
19464 {
19465 return qe_invalid;
19466 }
19467
19468
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if(!p_getc(&temp,f))
19469 {
19470 return qe_invalid;
19471 }
19472
19473 44 addOldStyleFamily(&temp_zinit, itemsbuf, itype_potion, temp);
19474
19475
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if(!p_getc(&tempwhistle,f))
19476 {
19477 return qe_invalid;
19478 }
19479
19480 //old only
19481
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
44 if((Header->zelda_version == 0x192)&&(Header->build<174))
19482 {
19483
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempcandle=(tempcandle)?(1<<(tempcandle-1)):0;
19484
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempboomerang=(tempboomerang)?(1<<(tempboomerang-1)):0;
19485
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 temparrow=(temparrow)?(1<<(temparrow-1)):0;
19486
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempwhistle=(tempwhistle)?(1<<(tempwhistle-1)):0;
19487 4 }
19488
19489 44 addOldStyleFamily(&temp_zinit, itemsbuf, itype_candle, tempcandle);
19490 44 addOldStyleFamily(&temp_zinit, itemsbuf, itype_brang, tempboomerang);
19491 44 addOldStyleFamily(&temp_zinit, itemsbuf, itype_arrow, temparrow);
19492 44 addOldStyleFamily(&temp_zinit, itemsbuf, itype_whistle, tempwhistle);
19493 //What about the potion...?
19494
19495 44 }
19496
19497
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 176 times.
194 if(s_version < 29)
19498 {
19499 //Oh sure, stick these IN THE MIDDLE OF THE ITEMS, just to make me want
19500 //to jab out my eye...
19501
1/2
✓ Branch 0 taken 176 times.
✗ Branch 1 not taken.
176 if(!p_getc(&padding,f))
19502 return qe_invalid;
19503 176 temp_zinit.counter[crBOMBS] = padding;
19504
19505
1/2
✓ Branch 0 taken 176 times.
✗ Branch 1 not taken.
176 if(!p_getc(&padding,f))
19506 return qe_invalid;
19507 176 temp_zinit.counter[crSBOMBS] = padding;
19508 176 }
19509
19510 //Back to more OLD item code
19511
2/2
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 44 times.
194 if(s_version < 10)
19512 {
19513
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
49 if((Header->zelda_version > 0x192)||
19514 //new only
19515
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19516 {
19517
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(!p_getc(&temp,f))
19518 {
19519 return qe_invalid;
19520 }
19521
19522 40 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wand, temp);
19523
19524
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(!p_getc(&temp,f))
19525 {
19526 return qe_invalid;
19527 }
19528
19529 40 addOldStyleFamily(&temp_zinit, itemsbuf, itype_letter, temp);
19530
19531
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(!p_getc(&temp,f))
19532 {
19533 return qe_invalid;
19534 }
19535
19536 40 addOldStyleFamily(&temp_zinit, itemsbuf, itype_lens, temp);
19537
19538
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(!p_getc(&temp,f))
19539 {
19540 return qe_invalid;
19541 }
19542
19543 40 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hookshot, temp);
19544
19545
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(!p_getc(&temp,f))
19546 {
19547 return qe_invalid;
19548 }
19549
19550 40 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bait, temp);
19551
19552
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(!p_getc(&temp,f))
19553 {
19554 return qe_invalid;
19555 }
19556
19557 40 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hammer, temp);
19558
19559
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(!p_getc(&temp,f))
19560 {
19561 return qe_invalid;
19562 }
19563
19564 40 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divinefire, temp);
19565
19566
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(!p_getc(&temp,f))
19567 {
19568 return qe_invalid;
19569 }
19570
19571 40 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineescape, temp);
19572
19573
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(!p_getc(&temp,f))
19574 {
19575 return qe_invalid;
19576 }
19577
19578 40 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineprotection, temp);
19579
19580
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(!p_getc(&temp,f))
19581 {
19582 return qe_invalid;
19583 }
19584
19585
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 1 times.
40 if(Header->zelda_version == 0x192)
19586 {
19587
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 1 times.
33 for(int32_t q=0; q<32; q++)
19588 {
19589
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(!p_getc(&padding,f))
19590 {
19591 return qe_invalid;
19592 }
19593 32 }
19594 1 }
19595 40 }
19596 44 }
19597
19598 //old only
19599
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 189 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
194 if((Header->zelda_version == 0x192)&&(Header->build<174))
19600 {
19601 byte equipment, tmpitm; //bit flags
19602
19603
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&equipment,f))
19604 {
19605 return qe_invalid;
19606 }
19607
19608 4 temp_zinit.set_item(iRaft, get_bit(&equipment, idE_RAFT)!=0);
19609 4 temp_zinit.set_item(iLadder, get_bit(&equipment, idE_LADDER)!=0);
19610 4 temp_zinit.set_item(iBook, get_bit(&equipment, idE_BOOK)!=0);
19611 4 temp_zinit.set_item(iMKey, get_bit(&equipment, idE_KEY)!=0);
19612 4 temp_zinit.set_item(iFlippers, get_bit(&equipment, idE_FLIPPERS)!=0);
19613 4 temp_zinit.set_item(iBoots, get_bit(&equipment, idE_BOOTS)!=0);
19614
19615
19616
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tmpitm,f))
19617 {
19618 return qe_invalid;
19619 }
19620
19621 4 temp_zinit.set_item(iWand, get_bit(&tmpitm, idI_WAND)!=0);
19622 4 temp_zinit.set_item(iLetter, get_bit(&tmpitm, idI_LETTER)!=0);
19623 4 temp_zinit.set_item(iLens, get_bit(&tmpitm, idI_LENS)!=0);
19624 4 temp_zinit.set_item(iHookshot, get_bit(&tmpitm, idI_HOOKSHOT)!=0);
19625 4 temp_zinit.set_item(iBait, get_bit(&tmpitm, idI_BAIT)!=0);
19626 4 temp_zinit.set_item(iHammer, get_bit(&tmpitm, idI_HAMMER)!=0);
19627 4 }
19628
19629
1/2
✓ Branch 0 taken 194 times.
✗ Branch 1 not taken.
194 if(!p_getc(&tempbyte,f))
19630 return qe_invalid;
19631 194 temp_zinit.mcounter[crLIFE] = tempbyte;
19632
19633
19634
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 150 times.
194 if(s_version < 14)
19635 {
19636 byte temphp;
19637
19638
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if(!p_getc(&temphp,f))
19639 {
19640 return qe_invalid;
19641 }
19642
19643 44 temp_zinit.counter[crLIFE]=temphp;
19644
19645
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if(!p_getc(&temphp,f))
19646 {
19647 return qe_invalid;
19648 }
19649
19650 44 temp_zinit.cont_heart=temphp;
19651 44 }
19652 else
19653 {
19654
1/2
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
150 if(!p_igetw(&temp_zinit.counter[crLIFE],f))
19655 {
19656 return qe_invalid;
19657 }
19658
19659
1/2
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
150 if(!p_igetw(&temp_zinit.cont_heart,f))
19660 {
19661 return qe_invalid;
19662 }
19663 }
19664
19665
1/2
✓ Branch 0 taken 194 times.
✗ Branch 1 not taken.
194 if(!p_getc(&temp_zinit.hcp,f))
19666 {
19667 return qe_invalid;
19668 }
19669
19670
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 150 times.
194 if(s_version >= 14)
19671 {
19672
1/2
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
150 if(!p_getc(&temp_zinit.hcp_per_hc,f))
19673 {
19674 return qe_invalid;
19675 }
19676
19677
1/2
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
150 if(s_version<16) // July 2007
19678 {
19679 if(get_qr(qr_BRANGPICKUP+1))
19680 temp_zinit.hcp_per_hc = 0xFF;
19681
19682 //Dispose of legacy rule
19683 set_qr(qr_BRANGPICKUP+1, 0);
19684 }
19685 150 }
19686
19687
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 176 times.
194 if(s_version < 29)
19688 {
19689
1/2
✓ Branch 0 taken 176 times.
✗ Branch 1 not taken.
176 if(!p_getc(&padding,f))
19690 return qe_invalid;
19691 176 temp_zinit.mcounter[crBOMBS] = padding;
19692 176 }
19693
19694
1/2
✓ Branch 0 taken 194 times.
✗ Branch 1 not taken.
194 if(!p_getc(&temp_zinit.counter[crKEYS],f))
19695 {
19696 return qe_invalid;
19697 }
19698
19699
1/2
✓ Branch 0 taken 194 times.
✗ Branch 1 not taken.
194 if(!p_igetw(&temp_zinit.counter[crMONEY],f))
19700 {
19701 return qe_invalid;
19702 }
19703
19704
1/2
✓ Branch 0 taken 194 times.
✗ Branch 1 not taken.
194 if(!p_getc(&tempbyte,f))
19705 return qe_invalid;
19706
2/2
✓ Branch 0 taken 1552 times.
✓ Branch 1 taken 194 times.
1746 for(int q = 0; q < 8; ++q)
19707 1552 set_bit(temp_zinit.mcguffin, q+1, get_bitl(tempbyte, q));
19708
19709
3/6
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 150 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 44 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
194 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
19710 {
19711
2/2
✓ Branch 0 taken 9600 times.
✓ Branch 1 taken 150 times.
9750 for(int32_t i=0; i<64; i++)
19712 {
19713
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9600 times.
9600 if(!p_getc(&temp_zinit.map[i],f))
19714 {
19715 return qe_invalid;
19716 }
19717 9600 }
19718
19719
2/2
✓ Branch 0 taken 9600 times.
✓ Branch 1 taken 150 times.
9750 for(int32_t i=0; i<64; i++)
19720 {
19721
1/2
✓ Branch 0 taken 9600 times.
✗ Branch 1 not taken.
9600 if(!p_getc(&temp_zinit.compass[i],f))
19722 {
19723 return qe_invalid;
19724 }
19725 9600 }
19726 150 }
19727 else
19728 {
19729
2/2
✓ Branch 0 taken 1408 times.
✓ Branch 1 taken 44 times.
1452 for(int32_t i=0; i<32; i++)
19730 {
19731
1/2
✓ Branch 0 taken 1408 times.
✗ Branch 1 not taken.
1408 if(!p_getc(&temp_zinit.map[i],f))
19732 {
19733 return qe_invalid;
19734 }
19735 1408 }
19736
19737
2/2
✓ Branch 0 taken 1408 times.
✓ Branch 1 taken 44 times.
1452 for(int32_t i=0; i<32; i++)
19738 {
19739
1/2
✓ Branch 0 taken 1408 times.
✗ Branch 1 not taken.
1408 if(!p_getc(&temp_zinit.compass[i],f))
19740 {
19741 return qe_invalid;
19742 }
19743 1408 }
19744 }
19745
19746
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 189 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
199 if((Header->zelda_version > 0x192)||
19747 //new only
19748
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19749 {
19750
3/6
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 150 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 40 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
190 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
19751 {
19752
2/2
✓ Branch 0 taken 9600 times.
✓ Branch 1 taken 150 times.
9750 for(int32_t i=0; i<64; i++)
19753 {
19754
1/2
✓ Branch 0 taken 9600 times.
✗ Branch 1 not taken.
9600 if(!p_getc(&temp_zinit.boss_key[i],f))
19755 {
19756 return qe_invalid;
19757 }
19758 9600 }
19759 150 }
19760 else
19761 {
19762
2/2
✓ Branch 0 taken 1280 times.
✓ Branch 1 taken 40 times.
1320 for(int32_t i=0; i<32; i++)
19763 {
19764
1/2
✓ Branch 0 taken 1280 times.
✗ Branch 1 not taken.
1280 if(!p_getc(&temp_zinit.boss_key[i],f))
19765 {
19766 return qe_invalid;
19767 }
19768 1280 }
19769 }
19770 190 }
19771
19772 byte tmpmisc[16];
19773
2/2
✓ Branch 0 taken 3104 times.
✓ Branch 1 taken 194 times.
3298 for(int32_t i=0; i<16; i++)
19774
1/2
✓ Branch 0 taken 3104 times.
✗ Branch 1 not taken.
3104 if(!p_getc(&tmpmisc[i],f))
19775 return qe_invalid;
19776 194 temp_zinit.flags.set(INIT_FL_CONTPERCENT,get_bit(tmpmisc,0));
19777 194 temp_zinit.magicdrainrate = get_bit(tmpmisc,1) ? 1 : 2; //Double Magic flag
19778 194 temp_zinit.flags.set(INIT_FL_CANSLASH,get_bit(tmpmisc,2));
19779
19780
4/4
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 44 times.
✓ Branch 2 taken 176 times.
✓ Branch 3 taken 44 times.
370 if(s_version < 15) for(int32_t i=0; i<4; i++)
19781
1/2
✓ Branch 0 taken 176 times.
✗ Branch 1 not taken.
176 if(!p_getc(&sword_hearts[i],f))
19782 44 return qe_invalid;
19783
19784
1/2
✓ Branch 0 taken 194 times.
✗ Branch 1 not taken.
194 if(!p_getc(&temp_zinit.last_map,f))
19785 {
19786 return qe_invalid;
19787 }
19788
19789
1/2
✓ Branch 0 taken 194 times.
✗ Branch 1 not taken.
194 if(!p_getc(&temp_zinit.last_screen,f))
19790 {
19791 return qe_invalid;
19792 }
19793
19794
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 150 times.
194 if(s_version < 14)
19795 {
19796 byte tempmp;
19797
19798
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if(!p_getc(&tempmp,f))
19799 {
19800 return qe_invalid;
19801 }
19802
19803 44 temp_zinit.mcounter[crMAGIC]=tempmp;
19804
19805
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if(!p_getc(&tempmp,f))
19806 {
19807 return qe_invalid;
19808 }
19809
19810 44 temp_zinit.counter[crMAGIC]=tempmp;
19811 44 }
19812 else
19813 {
19814
1/2
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
150 if(!p_igetw(&temp_zinit.mcounter[crMAGIC],f))
19815 {
19816 return qe_invalid;
19817 }
19818
19819
1/2
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
150 if(!p_igetw(&temp_zinit.counter[crMAGIC],f))
19820 {
19821 return qe_invalid;
19822 }
19823 }
19824
19825
19826
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 150 times.
194 if(s_version < 15)
19827 {
19828
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 if(s_version < 12)
19829 {
19830 44 temp_zinit.mcounter[crMAGIC]*=32;
19831 44 temp_zinit.counter[crMAGIC]*=32;
19832 44 }
19833
19834
2/2
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 44 times.
220 for(int32_t i=0; i<4; i++)
19835 {
19836
1/2
✓ Branch 0 taken 176 times.
✗ Branch 1 not taken.
176 if(!p_getc(&beam_hearts[i],f))
19837 {
19838 return qe_invalid;
19839 }
19840 176 }
19841
19842
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if(!p_getc(&beam_percent,f))
19843 {
19844 return qe_invalid;
19845 }
19846 44 }
19847 else
19848 {
19849
1/2
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
150 if(!p_getc(&temp_zinit.bomb_ratio,f))
19850 return qe_invalid;
19851
1/2
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
150 if(temp_zinit.bomb_ratio < 1)
19852 temp_zinit.bomb_ratio = 1;
19853 150 else bomb_ratio = temp_zinit.bomb_ratio; //jank
19854 }
19855
19856
2/2
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 44 times.
194 if(s_version < 15)
19857 {
19858 byte tempbp;
19859
19860
2/2
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 44 times.
220 for(int32_t i=0; i<4; i++)
19861 {
19862
2/4
✓ Branch 0 taken 176 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 176 times.
✗ Branch 3 not taken.
176 if(!(s_version < 14 ? p_getc(&tempbp,f) : p_igetw(&tempbp,f)))
19863 {
19864 return qe_invalid;
19865 }
19866
19867 176 beam_power[i]=tempbp;
19868 176 }
19869
19870
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if(!p_getc(&hookshot_links,f))
19871 {
19872 return qe_invalid;
19873 }
19874
19875
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if(s_version>6)
19876 {
19877 if(!p_getc(&hookshot_length,f))
19878 {
19879 return qe_invalid;
19880 }
19881
19882 if(!p_getc(&longshot_links,f))
19883 {
19884 return qe_invalid;
19885 }
19886
19887 if(!p_getc(&longshot_length,f))
19888 {
19889 return qe_invalid;
19890 }
19891 }
19892 44 }
19893
19894
1/2
✓ Branch 0 taken 194 times.
✗ Branch 1 not taken.
194 if(!p_getc(&temp_zinit.msg_more_x,f))
19895 {
19896 return qe_invalid;
19897 }
19898
19899
1/2
✓ Branch 0 taken 194 times.
✗ Branch 1 not taken.
194 if(!p_getc(&temp_zinit.msg_more_y,f))
19900 {
19901 return qe_invalid;
19902 }
19903
19904
1/2
✓ Branch 0 taken 194 times.
✗ Branch 1 not taken.
194 if(!p_getc(&subscr_mode,f))
19905 return qe_invalid;
19906
19907 //old only
19908
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 189 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
194 if((Header->zelda_version == 0x192)&&(Header->build<174))
19909 {
19910
2/2
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 4 times.
132 for(int32_t i=0; i<32; i++)
19911 {
19912
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!p_getc(&temp_zinit.boss_key[i],f))
19913 {
19914 return qe_invalid;
19915 }
19916 128 }
19917 4 }
19918
19919
5/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 189 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 4 times.
194 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>173))) //new only
19920 {
19921
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 150 times.
190 if(s_version <= 10)
19922 {
19923
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(!p_getc(&tempbyte,f))
19924 {
19925 return qe_invalid;
19926 }
19927
19928 40 temp_zinit.start_dmap = (word)tempbyte;
19929 40 }
19930 else
19931 {
19932
1/2
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
150 if(!p_igetw(&temp_zinit.start_dmap,f))
19933 {
19934 return qe_invalid;
19935 }
19936 }
19937
19938
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if(!p_getc(&temp_zinit.heroAnimationStyle,f))
19939 {
19940 return qe_invalid;
19941 }
19942 190 }
19943
19944
4/4
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 44 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 132 times.
194 if(s_version>1 && s_version < 29)
19945 {
19946
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(!p_getc(&padding,f))
19947 return qe_invalid;
19948 132 temp_zinit.counter[crARROWS] = padding;
19949
19950
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(!p_getc(&padding,f))
19951 return qe_invalid;
19952 132 temp_zinit.mcounter[crARROWS] = padding;
19953 132 }
19954
19955
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 150 times.
194 if(s_version>2)
19956 {
19957
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 150 times.
150 if(s_version <= 10)
19958 {
19959 for(int32_t i=0; i<OLDMAXLEVELS; i++)
19960 {
19961 if(!p_getc(&(temp_zinit.level_keys[i]),f))
19962 {
19963 return qe_invalid;
19964 }
19965 }
19966 }
19967 else
19968 {
19969
2/2
✓ Branch 0 taken 76800 times.
✓ Branch 1 taken 150 times.
76950 for(int32_t i=0; i<MAXLEVELS; i++)
19970 {
19971
1/2
✓ Branch 0 taken 76800 times.
✗ Branch 1 not taken.
76800 if(!p_getc(&(temp_zinit.level_keys[i]),f))
19972 {
19973 return qe_invalid;
19974 }
19975 76800 }
19976 }
19977 150 }
19978
19979
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 150 times.
194 if(s_version>3)
19980 {
19981
1/2
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
150 if(!p_igetw(&temp_zinit.ss_grid_x,f))
19982 {
19983 return qe_invalid;
19984 }
19985
19986
1/2
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
150 if(!p_igetw(&temp_zinit.ss_grid_y,f))
19987 {
19988 return qe_invalid;
19989 }
19990
19991
1/2
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
150 if(!p_igetw(&temp_zinit.ss_grid_xofs,f))
19992 {
19993 return qe_invalid;
19994 }
19995
19996
1/2
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
150 if(!p_igetw(&temp_zinit.ss_grid_yofs,f))
19997 {
19998 return qe_invalid;
19999 }
20000
20001
1/2
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
150 if(!p_igetw(&temp_zinit.ss_grid_color,f))
20002 {
20003 return qe_invalid;
20004 }
20005
20006
1/2
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
150 if(!p_igetw(&temp_zinit.ss_bbox_1_color,f))
20007 {
20008 return qe_invalid;
20009 }
20010
20011
1/2
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
150 if(!p_igetw(&temp_zinit.ss_bbox_2_color,f))
20012 {
20013 return qe_invalid;
20014 }
20015
20016
1/2
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
150 if(!p_igetw(&temp_zinit.ss_flags,f))
20017 {
20018 return qe_invalid;
20019 }
20020
20021
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 150 times.
150 temp_zinit.ss_grid_x=zc_max(temp_zinit.ss_grid_x,1);
20022
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 150 times.
150 temp_zinit.ss_grid_y=zc_max(temp_zinit.ss_grid_y,1);
20023 150 }
20024
20025
3/4
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 44 times.
✓ Branch 2 taken 150 times.
✗ Branch 3 not taken.
194 if(s_version>4 && s_version<15)
20026 {
20027 if(!p_getc(&moving_fairy_hearts,f))
20028 {
20029 return qe_invalid;
20030 }
20031
20032 if(!p_getc(&moving_fairy_heart_percent,f))
20033 {
20034 return qe_invalid;
20035 }
20036 }
20037
20038
3/4
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 44 times.
✓ Branch 2 taken 150 times.
✗ Branch 3 not taken.
194 if(s_version>5 && s_version < 10)
20039 {
20040 if(!p_getc(&temp,f))
20041 {
20042 return qe_invalid;
20043 }
20044
20045 addOldStyleFamily(&temp_zinit, itemsbuf, itype_quiver, temp);
20046 }
20047
20048
3/4
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 44 times.
✓ Branch 2 taken 150 times.
✗ Branch 3 not taken.
194 if(s_version>6 && s_version<15)
20049 {
20050 if(!p_getc(&stationary_fairy_hearts,f))
20051 {
20052 return qe_invalid;
20053 }
20054
20055 if(!p_getc(&stationary_fairy_heart_percent,f))
20056 {
20057 return qe_invalid;
20058 }
20059
20060 if(!p_getc(&moving_fairy_magic,f))
20061 {
20062 return qe_invalid;
20063 }
20064
20065 if(!p_getc(&moving_fairy_magic_percent,f))
20066 {
20067 return qe_invalid;
20068 }
20069
20070 if(!p_getc(&stationary_fairy_magic,f))
20071 {
20072 return qe_invalid;
20073 }
20074
20075 if(!p_getc(&stationary_fairy_magic_percent,f))
20076 {
20077 return qe_invalid;
20078 }
20079
20080 if(!p_getc(&blue_potion_hearts,f))
20081 {
20082 return qe_invalid;
20083 }
20084
20085 if(!p_getc(&blue_potion_heart_percent,f))
20086 {
20087 return qe_invalid;
20088 }
20089
20090 if(!p_getc(&red_potion_hearts,f))
20091 {
20092 return qe_invalid;
20093 }
20094
20095 if(!p_getc(&red_potion_heart_percent,f))
20096 {
20097 return qe_invalid;
20098 }
20099
20100 if(!p_getc(&blue_potion_magic,f))
20101 {
20102 return qe_invalid;
20103 }
20104
20105 if(!p_getc(&blue_potion_magic_percent,f))
20106 {
20107 return qe_invalid;
20108 }
20109
20110 if(!p_getc(&red_potion_magic,f))
20111 {
20112 return qe_invalid;
20113 }
20114
20115 if(!p_getc(&red_potion_magic_percent,f))
20116 {
20117 return qe_invalid;
20118 }
20119 }
20120
20121
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 150 times.
194 if(s_version>6)
20122
1/2
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
150 if(!p_getc(&padding,f))
20123 return qe_invalid;
20124
20125
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 150 times.
194 if(s_version>7)
20126 {
20127
1/2
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
150 if(!p_getc(&padding,f))
20128 {
20129 return qe_invalid;
20130 }
20131 150 }
20132
20133
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 150 times.
194 if(s_version>8)
20134 {
20135
1/2
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
150 if(!p_igetw(&temp_zinit.mcounter[crMONEY],f))
20136 {
20137 return qe_invalid;
20138 }
20139
20140
1/2
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
150 if(!p_igetw(&temp_zinit.mcounter[crKEYS],f))
20141 {
20142 return qe_invalid;
20143 }
20144 150 }
20145
20146
2/2
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 44 times.
194 if(s_version>16)
20147 {
20148
1/2
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
150 if(!p_getc(&tempbyte,f))
20149 {
20150 return qe_invalid;
20151 }
20152 150 temp_zinit.gravity = tempbyte*100;
20153
1/2
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
150 if(!p_igetw(&temp_zinit.terminalv,f))
20154 {
20155 return qe_invalid;
20156 }
20157
20158
1/2
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
150 if(!p_getc(&temp_zinit.msg_speed,f))
20159 {
20160 return qe_invalid;
20161 }
20162
20163
1/2
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
150 if(!p_getc(&padding,f))
20164 {
20165 return qe_invalid;
20166 }
20167
20168
1/2
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
150 if(!p_getc(&temp_zinit.jump_hero_layer_threshold,f))
20169 {
20170 return qe_invalid;
20171 }
20172 150 }
20173
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 11 times.
44 else if (replay_version_check(0, 13))
20174 11 temp_zinit.msg_speed = 0;
20175
20176
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 150 times.
194 if(s_version>17)
20177 {
20178
1/2
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
150 if(!p_getc(&temp_zinit.msg_more_is_offset,f))
20179 {
20180 return qe_invalid;
20181 }
20182 150 }
20183
20184 //expaned init data for larger values in 2.55
20185
2/2
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 18 times.
194 if ( s_version >= 19 ) //expand init data bombs, sbombs, and arrows to 0xFFFF
20186 {
20187
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetw(&temp_zinit.counter[crBOMBS],f))
20188 {
20189 return qe_invalid;
20190 }
20191
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetw(&temp_zinit.counter[crSBOMBS],f))
20192 {
20193 return qe_invalid;
20194 }
20195
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetw(&temp_zinit.mcounter[crBOMBS],f))
20196 {
20197 return qe_invalid;
20198 }
20199
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetw(&temp_zinit.mcounter[crSBOMBS],f))
20200 {
20201 return qe_invalid;
20202 }
20203
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetw(&temp_zinit.counter[crARROWS],f))
20204 {
20205 return qe_invalid;
20206 }
20207
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetw(&temp_zinit.mcounter[crARROWS],f))
20208 {
20209 return qe_invalid;
20210 }
20211
20212 18 }
20213
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 176 times.
194 if ( s_version >= 20 )
20214 {
20215
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetw(&temp_zinit.heroStep,f))
20216 {
20217 return qe_invalid;
20218 }
20219 18 }
20220 else
20221 {
20222 176 temp_zinit.heroStep = 150; //1.5 pixels per frame
20223 }
20224
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 176 times.
194 if ( s_version >= 21 )
20225 {
20226
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetw(&temp_zinit.subscrSpeed,f))
20227 {
20228 return qe_invalid;
20229 }
20230 18 }
20231 else
20232 {
20233 176 temp_zinit.subscrSpeed = 1; //3 pixels per frame
20234 }
20235 //old only
20236
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 189 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
194 if((Header->zelda_version == 0x192)&&(Header->build<174))
20237 {
20238 byte items2;
20239
20240
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&items2,f))
20241 {
20242 return qe_invalid;
20243 }
20244
20245 4 temp_zinit.set_item(iDivineFire, get_bit(&items2, idI_DFIRE)!=0);
20246 4 temp_zinit.set_item(iDivineEscape, get_bit(&items2, idI_FWIND)!=0);
20247 4 temp_zinit.set_item(iDivineProtection, get_bit(&items2, idI_NLOVE)!=0);
20248 4 }
20249
20250
2/2
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 5 times.
194 if(Header->zelda_version < 0x193)
20251 {
20252
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 5 times.
485 for(int32_t q=0; q<96; q++)
20253 {
20254
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 if(!p_getc(&padding,f))
20255 {
20256 return qe_invalid;
20257 }
20258 480 }
20259
20260 //new only
20261
3/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1 times.
5 if((Header->zelda_version == 0x192)&&(Header->build>173))
20262 {
20263
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_getc(&padding,f))
20264 {
20265 return qe_invalid;
20266 }
20267
20268
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_getc(&padding,f))
20269 {
20270 return qe_invalid;
20271 }
20272 1 }
20273 5 }
20274 194 }
20275
20276
3/6
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 62 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 150 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
212 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<15)))
20277 {
20278 //temp_zinit.shield=i_smallshield;
20279 62 int32_t sshieldid = getItemID(itemsbuf, itype_shield, i_smallshield);
20280
20281
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(sshieldid != -1)
20282 62 temp_zinit.set_item(sshieldid, true);
20283 62 }
20284
20285
5/6
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 189 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
212 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<27)))
20286 {
20287 18 temp_zinit.mcounter[crLIFE]=3;
20288 18 temp_zinit.counter[crLIFE]=3;
20289 18 temp_zinit.cont_heart=3;
20290 18 temp_zinit.mcounter[crBOMBS]=8;
20291 18 }
20292
20293
5/6
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 189 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
212 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<50)))
20294 {
20295 18 sword_hearts[0]=0;
20296 18 sword_hearts[1]=5;
20297 18 sword_hearts[2]=12;
20298 18 sword_hearts[3]=21;
20299 18 }
20300
20301
5/6
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 189 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
212 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<51)))
20302 {
20303 18 temp_zinit.last_map=0;
20304 18 temp_zinit.last_screen=0;
20305 18 }
20306
20307
5/6
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 189 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
212 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<68)))
20308 {
20309 18 temp_zinit.mcounter[crMAGIC]=0;
20310 18 temp_zinit.counter[crMAGIC]=0;
20311 18 temp_zinit.magicdrainrate = 2;
20312 18 }
20313
20314
5/6
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 189 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
212 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<129)))
20315 {
20316
20317
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
90 for(int32_t x=0; x<4; x++)
20318 {
20319 72 beam_hearts[x]=100;
20320 72 }
20321
20322
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
90 for(int32_t i=0; i<idBP_MAX; i++)
20323 {
20324 72 set_bit(&beam_percent,i,!get_qr(qr_LENSHINTS+i));
20325 72 set_qr(qr_LENSHINTS+i,0);
20326 72 }
20327
20328
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
90 for(int32_t x=0; x<4; x++)
20329 {
20330 72 beam_power[x]=get_qr(qr_HIDECARRIEDITEMS)?50:100;
20331 72 }
20332
20333 18 set_qr(qr_HIDECARRIEDITEMS,0);
20334 18 hookshot_links=100;
20335 18 temp_zinit.msg_more_x=224;
20336 18 temp_zinit.msg_more_y=64;
20337 18 }
20338
20339 // Okay, let's put these legacy values into itemsbuf.
20340
2/2
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 62 times.
212 if(s_version < 15)
20341
2/2
✓ Branch 0 taken 15872 times.
✓ Branch 1 taken 62 times.
15934 for(int32_t i=0; i<MAXITEMS; i++)
20342 {
20343
11/11
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 62 times.
✓ Branch 2 taken 62 times.
✓ Branch 3 taken 62 times.
✓ Branch 4 taken 62 times.
✓ Branch 5 taken 62 times.
✓ Branch 6 taken 62 times.
✓ Branch 7 taken 62 times.
✓ Branch 8 taken 15252 times.
✓ Branch 9 taken 62 times.
✓ Branch 10 taken 62 times.
15872 switch(i)
20344 {
20345 case iFairyStill:
20346 62 itemsbuf[i].misc1 = stationary_fairy_hearts;
20347 62 itemsbuf[i].misc2 = stationary_fairy_magic;
20348 62 itemsbuf[i].misc3 = 0;
20349 62 itemsbuf[i].flags |= stationary_fairy_heart_percent ? ITEM_FLAG1 : 0;
20350 62 itemsbuf[i].flags |= stationary_fairy_magic_percent ? ITEM_FLAG2 : 0;
20351 62 break;
20352
20353 case iFairyMoving:
20354 62 itemsbuf[i].misc1 = moving_fairy_hearts;
20355 62 itemsbuf[i].misc2 = moving_fairy_magic;
20356 62 itemsbuf[i].misc3 = 50;
20357 62 itemsbuf[i].flags |= moving_fairy_heart_percent ? ITEM_FLAG1 : 0;
20358 62 itemsbuf[i].flags |= moving_fairy_magic_percent ? ITEM_FLAG2 : 0;
20359 62 break;
20360
20361 case iRPotion:
20362 62 itemsbuf[i].misc1 = red_potion_hearts;
20363 62 itemsbuf[i].misc2 = red_potion_magic;
20364 62 itemsbuf[i].flags |= red_potion_heart_percent ? ITEM_FLAG1 : 0;
20365 62 itemsbuf[i].flags |= red_potion_magic_percent ? ITEM_FLAG2 : 0;
20366 62 break;
20367
20368 case iBPotion:
20369 62 itemsbuf[i].misc1 = blue_potion_hearts;
20370 62 itemsbuf[i].misc2 = blue_potion_magic;
20371 62 itemsbuf[i].flags |= blue_potion_heart_percent ? ITEM_FLAG1 : 0;
20372 62 itemsbuf[i].flags |= blue_potion_magic_percent ? ITEM_FLAG2 : 0;
20373 62 break;
20374
20375 case iSword:
20376 62 itemsbuf[i].pickup_hearts = sword_hearts[0];
20377 62 itemsbuf[i].misc1 = beam_hearts[0];
20378 62 itemsbuf[i].misc2 = beam_power[0];
20379 // It seems that ITEM_FLAG1 was already added by reset_itembuf()...
20380 62 itemsbuf[i].flags &= (!get_bit(&beam_percent,0)) ? ~ITEM_FLAG1 : ~0;
20381 62 break;
20382
20383 case iWSword:
20384 62 itemsbuf[i].pickup_hearts = sword_hearts[1];
20385 62 itemsbuf[i].misc1 = beam_hearts[1];
20386 62 itemsbuf[i].misc2 = beam_power[1];
20387 62 itemsbuf[i].flags &= (!get_bit(&beam_percent,1)) ? ~ITEM_FLAG1 : ~0;
20388 62 break;
20389
20390 case iMSword:
20391 62 itemsbuf[i].pickup_hearts = sword_hearts[2];
20392 62 itemsbuf[i].misc1 = beam_hearts[2];
20393 62 itemsbuf[i].misc2 = beam_power[2];
20394 62 itemsbuf[i].flags &= (!get_bit(&beam_percent,2)) ? ~ITEM_FLAG1 : ~0;
20395 62 break;
20396
20397 case iXSword:
20398 62 itemsbuf[i].pickup_hearts = sword_hearts[3];
20399 62 itemsbuf[i].misc1 = beam_hearts[3];
20400 62 itemsbuf[i].misc2 = beam_power[3];
20401 62 itemsbuf[i].flags &= (!get_bit(&beam_percent,3)) ? ~ITEM_FLAG1 : ~0;
20402 62 break;
20403
20404 case iHookshot:
20405 62 itemsbuf[i].misc1 = hookshot_length;
20406 62 itemsbuf[i].misc2 = hookshot_links;
20407 62 break;
20408
20409 case iLongshot:
20410 62 itemsbuf[i].misc1 = longshot_length;
20411 62 itemsbuf[i].misc2 = longshot_links;
20412 62 break;
20413 }
20414 15934 }
20415
20416
6/6
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 189 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 1 times.
212 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<168)))
20417 {
20418 //was new subscreen rule
20419 22 subscr_mode=get_qr(qr_FREEFORM)?1:0;
20420 22 set_qr(qr_FREEFORM,0);
20421 22 }
20422
20423
5/6
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 189 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
212 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<185)))
20424 {
20425 23 temp_zinit.start_dmap=0;
20426 23 }
20427
20428
5/6
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 189 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
212 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<186)))
20429 {
20430 23 temp_zinit.heroAnimationStyle=get_qr(qr_BSZELDA)?1:0;
20431 23 }
20432
20433
3/4
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 150 times.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
212 if(s_version < 16 && get_bit(deprecated_rules, qr_COOLSCROLL+1))
20434 {
20435 //addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, 4); //is this needed?
20436 temp_zinit.mcounter[crMONEY]=999;
20437 //temp_zinit.counter[crMONEY]=999; //This rule only gave you an invisible max wallet; it did not give you max rupies.
20438 }
20439
2/2
✓ Branch 0 taken 206 times.
✓ Branch 1 taken 6 times.
212 if(Header->zelda_version < 0x190) //1.84 bugfix. -Z
20440 {
20441 //temp_zinit.items[iBombBag] = true; //No, this is 30 max bombs!
20442 6 temp_zinit.mcounter[crBOMBS] = 8;
20443 6 }
20444 // al_trace("About to copy over new init data values for quest made in: %x\n", Header->zelda_version);
20445 //time to ensure that we port all new values properly:
20446
2/2
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 62 times.
212 if(Header->zelda_version < 0x250)
20447 {
20448
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 temp_zinit.mcounter[crSBOMBS] = bomb_ratio > 0 ? ( temp_zinit.mcounter[crBOMBS]/temp_zinit.bomb_ratio ) : (temp_zinit.mcounter[crBOMBS]/4);
20449 62 }
20450
20451
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 194 times.
212 if(s_version > 21)
20452 {
20453
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_getc(&temp_zinit.hp_per_heart,f))
20454 {
20455 return qe_invalid;
20456 }
20457
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_getc(&temp_zinit.magic_per_block,f))
20458 {
20459 return qe_invalid;
20460 }
20461
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_getc(&temp_zinit.hero_damage_multiplier,f))
20462 {
20463 return qe_invalid;
20464 }
20465
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_getc(&temp_zinit.ene_damage_multiplier,f))
20466 {
20467 return qe_invalid;
20468 }
20469 18 }
20470 else
20471 {
20472 194 temp_zinit.hp_per_heart = 16; //HP_PER_HEART, previously hardcoded
20473 194 temp_zinit.magic_per_block = 32; //MAGICPERBLOCK, previously hardcoded
20474 194 temp_zinit.hero_damage_multiplier = 2; //DAMAGE_MULTIPLIER, previously hardcoded
20475 194 temp_zinit.ene_damage_multiplier = 4; //(HP_PER_HEART/4), previously hardcoded
20476 }
20477
20478
2/2
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 18 times.
212 if(s_version > 22)
20479 {
20480
2/2
✓ Branch 0 taken 450 times.
✓ Branch 1 taken 18 times.
468 for(int32_t q = crCUSTOM1; q <= crCUSTOM25; ++q)
20481
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 450 times.
450 if(!p_igetw(&temp_zinit.counter[q],f))
20482 return qe_invalid;
20483
2/2
✓ Branch 0 taken 450 times.
✓ Branch 1 taken 18 times.
468 for(int32_t q = crCUSTOM1; q <= crCUSTOM25; ++q)
20484
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 450 times.
450 if(!p_igetw(&temp_zinit.mcounter[q],f))
20485 return qe_invalid;
20486 18 }
20487
20488
20489
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 194 times.
212 if(s_version > 23)
20490 {
20491
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_getc(&temp_zinit.dither_type,f))
20492 {
20493 return qe_invalid;
20494 }
20495
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_getc(&temp_zinit.dither_arg,f))
20496 {
20497 return qe_invalid;
20498 }
20499
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_getc(&temp_zinit.dither_percent,f))
20500 {
20501 return qe_invalid;
20502 }
20503
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_getc(&temp_zinit.def_lightrad,f))
20504 {
20505 return qe_invalid;
20506 }
20507
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_getc(&temp_zinit.transdark_percent,f))
20508 {
20509 return qe_invalid;
20510 }
20511 18 }
20512 else
20513 {
20514 194 temp_zinit.dither_type = 0;
20515 194 temp_zinit.dither_arg = 0;
20516 194 temp_zinit.dither_percent = 20;
20517 194 temp_zinit.def_lightrad = 24;
20518 194 temp_zinit.transdark_percent = 0;
20519 }
20520
20521
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 194 times.
212 if(s_version > 24)
20522 {
20523
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_getc(&temp_zinit.darkcol,f))
20524 {
20525 return qe_invalid;
20526 }
20527 18 }
20528 else
20529 {
20530 194 temp_zinit.darkcol = BLACK;
20531 }
20532
20533
2/2
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 18 times.
212 if(s_version > 25)
20534 {
20535
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetl(&temp_zinit.gravity,f))
20536 {
20537 return qe_invalid;
20538 }
20539
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetl(&temp_zinit.swimgravity,f))
20540 {
20541 return qe_invalid;
20542 }
20543 18 }
20544
20545
20546
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 194 times.
212 if(s_version > 26)
20547 {
20548
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetw(&temp_zinit.heroSideswimUpStep,f))
20549 {
20550 return qe_invalid;
20551 }
20552
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetw(&temp_zinit.heroSideswimSideStep,f))
20553 {
20554 return qe_invalid;
20555 }
20556
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetw(&temp_zinit.heroSideswimDownStep,f))
20557 {
20558 return qe_invalid;
20559 }
20560 18 }
20561 else
20562 {
20563 194 temp_zinit.heroSideswimUpStep = 150;
20564 194 temp_zinit.heroSideswimSideStep = 100;
20565 194 temp_zinit.heroSideswimDownStep = 75;
20566 }
20567
20568
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 194 times.
212 if(s_version > 27)
20569 {
20570
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetl(&temp_zinit.exitWaterJump,f))
20571 {
20572 return qe_invalid;
20573 }
20574 18 }
20575 else
20576 {
20577 194 temp_zinit.exitWaterJump = 0;
20578 }
20579
20580
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 194 times.
212 if(s_version > 29)
20581 {
20582
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetl(&temp_zinit.bunny_ltm,f))
20583 {
20584 return qe_invalid;
20585 }
20586 18 }
20587 else
20588 {
20589 194 temp_zinit.bunny_ltm = 0;
20590 }
20591
20592
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 194 times.
212 if(s_version > 30)
20593 {
20594
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_getc(&temp_zinit.switchhookstyle,f))
20595 {
20596 return qe_invalid;
20597 }
20598 18 }
20599 else
20600 {
20601 194 temp_zinit.switchhookstyle = 1;
20602 }
20603
20604
2/2
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 18 times.
212 if(s_version > 31)
20605 {
20606
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_getc(&temp_zinit.magicdrainrate,f))
20607 {
20608 return qe_invalid;
20609 }
20610 18 }
20611
20612 212 temp_zinit.clear_genscript();
20613
2/2
✓ Branch 0 taken 199 times.
✓ Branch 1 taken 13 times.
212 if(s_version > 32)
20614 {
20615 13 word numgenscript = 0;
20616
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetw(&numgenscript,f))
20617 return qe_invalid;
20618
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
13 if (!(numgenscript >= 0 && numgenscript <= NUMSCRIPTSGENERIC))
20619 return qe_invalid;
20620
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 for(auto q = 1; q < numgenscript; ++q)
20621 {
20622 if(!p_getc(&tempbyte,f))
20623 return qe_invalid;
20624 if(!(tempbyte&2))
20625 continue;
20626 temp_zinit.gen_doscript.set(q, tempbyte&1);
20627 if(!p_igetw(&temp_zinit.gen_exitState[q],f))
20628 return qe_invalid;
20629 if(!p_igetw(&temp_zinit.gen_reloadState[q],f))
20630 return qe_invalid;
20631 for(auto p = 0; p < 8; ++p)
20632 if(!p_igetl(&temp_zinit.gen_initd[q][p],f))
20633 return qe_invalid;
20634 dword sz;
20635 if(!p_igetl(&sz,f))
20636 return qe_invalid;
20637 temp_zinit.gen_data[q].resize(sz);
20638 std::vector<int32_t> dummy;
20639 if(!p_getlvec(&dummy,f))
20640 return qe_invalid;
20641 temp_zinit.gen_data[q] = dummy;
20642 if(!p_igetl(&temp_zinit.gen_eventstate[q],f))
20643 return qe_invalid;
20644 }
20645 13 }
20646
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 7 times.
212 if(s_version > 33)
20647 {
20648
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!p_getc(&temp_zinit.hero_swim_mult,f))
20649 return qe_invalid;
20650
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!p_getc(&temp_zinit.hero_swim_div,f))
20651 return qe_invalid;
20652 7 }
20653
1/2
✓ Branch 0 taken 212 times.
✗ Branch 1 not taken.
212 if(s_version > 34)
20654 {
20655 uint32_t num_used_mapscr_data;
20656 if(!p_igetl(&num_used_mapscr_data,f))
20657 return qe_invalid;
20658 for(uint32_t q = 0; q < num_used_mapscr_data; ++q)
20659 {
20660 uint32_t sz;
20661 if(!p_igetl(&sz,f))
20662 return qe_invalid;
20663 temp_zinit.screen_data[q].resize(sz);
20664 if(sz)
20665 {
20666 std::vector<int32_t> dummy;
20667 if(!p_getlvec(&dummy,f))
20668 return qe_invalid;
20669 temp_zinit.screen_data[q] = dummy;
20670 }
20671 }
20672 }
20673
1/2
✓ Branch 0 taken 212 times.
✗ Branch 1 not taken.
212 if (s_version > 35)
20674 if(!p_igetzf(&temp_zinit.shove_offset,f))
20675 return qe_invalid;
20676
20677 212 temp_zinit.counter[crLIFE] *= temp_zinit.hp_per_heart;
20678 212 temp_zinit.mcounter[crLIFE] *= temp_zinit.hp_per_heart;
20679
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 98 times.
212 if(!temp_zinit.flags.get(INIT_FL_CONTPERCENT))
20680 98 temp_zinit.cont_heart *= temp_zinit.hp_per_heart;
20681
20682 212 return 0;
20683 212 }
20684 588 int32_t readinitdata(PACKFILE *f, zquestheader *Header)
20685 {
20686 588 zinitdata temp_zinit = {};
20687
20688
3/4
✓ Branch 0 taken 565 times.
✓ Branch 1 taken 23 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
588 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_initdata);
20689
20690 int32_t dummy;
20691 588 word s_version=0, s_cversion=0;
20692 byte padding;
20693
20694
2/2
✓ Branch 0 taken 565 times.
✓ Branch 1 taken 23 times.
588 if(Header->zelda_version > 0x192)
20695 {
20696
2/4
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 565 times.
✗ Branch 3 not taken.
565 if(!p_igetw(&s_version,f))
20697 return qe_invalid;
20698 565 FFCore.quest_format[vInitData] = s_version;
20699
20700
2/4
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 565 times.
✗ Branch 3 not taken.
565 if(!p_igetw(&s_cversion,f))
20701 return qe_invalid;
20702
20703 //section size
20704
2/4
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 565 times.
✗ Branch 3 not taken.
565 if(!p_igetl(&dummy,f))
20705 return qe_invalid;
20706 565 }
20707
20708
2/2
✓ Branch 0 taken 212 times.
✓ Branch 1 taken 376 times.
588 if(s_version < 37)
20709 {
20710
2/4
✓ Branch 0 taken 212 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 212 times.
212 if(auto ret = readinitdata_old(f,Header,s_version,s_cversion,temp_zinit))
20711 return ret;
20712 212 }
20713 else
20714 {
20715 376 subscr_mode = ssdtMAX;
20716
2/2
✓ Branch 0 taken 12032 times.
✓ Branch 1 taken 376 times.
12408 for(int q = 0; q < MAXITEMS/8; ++q)
20717
2/4
✓ Branch 0 taken 12032 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12032 times.
12032 if(!p_getc(&temp_zinit.items[q], f))
20718 return qe_invalid;
20719
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 24064 times.
24440 for(int q = 0; q < MAXLEVELS/8; ++q)
20720 {
20721
2/4
✓ Branch 0 taken 24064 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24064 times.
✗ Branch 3 not taken.
24064 if(!p_getc(&temp_zinit.map[q], f))
20722 return qe_invalid;
20723
2/4
✓ Branch 0 taken 24064 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24064 times.
24064 if(!p_getc(&temp_zinit.compass[q], f))
20724 return qe_invalid;
20725
2/4
✓ Branch 0 taken 24064 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24064 times.
24064 if(!p_getc(&temp_zinit.boss_key[q], f))
20726 return qe_invalid;
20727
2/4
✓ Branch 0 taken 24064 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24064 times.
✗ Branch 3 not taken.
24064 if(!p_getc(&temp_zinit.mcguffin[q], f))
20728 return qe_invalid;
20729 24064 }
20730
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if(!p_getbvec(&temp_zinit.level_keys, f))
20731 return qe_invalid;
20732 byte num_counters;
20733
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if(!p_getc(&num_counters,f))
20734 return qe_invalid;
20735
2/2
✓ Branch 0 taken 40232 times.
✓ Branch 1 taken 376 times.
40608 for(int q = 0; q < num_counters; ++q)
20736
2/4
✓ Branch 0 taken 40232 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 40232 times.
40232 if(!p_igetw(&temp_zinit.counter[q],f))
20737 return qe_invalid;
20738
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 40232 times.
40608 for(int q = 0; q < num_counters; ++q)
20739
2/4
✓ Branch 0 taken 40232 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 40232 times.
40232 if(!p_igetw(&temp_zinit.mcounter[q],f))
20740 return qe_invalid;
20741
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if(!p_getc(&temp_zinit.bomb_ratio,f))
20742 return qe_invalid;
20743
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if(!p_getc(&temp_zinit.hcp,f))
20744 return qe_invalid;
20745
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if(!p_getc(&temp_zinit.hcp_per_hc,f))
20746 return qe_invalid;
20747
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if(!p_igetw(&temp_zinit.cont_heart,f))
20748 return qe_invalid;
20749
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if(!p_getc(&temp_zinit.hp_per_heart,f))
20750 return qe_invalid;
20751
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if(!p_getc(&temp_zinit.magic_per_block,f))
20752 return qe_invalid;
20753
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if(!p_getc(&temp_zinit.hero_damage_multiplier,f))
20754 return qe_invalid;
20755
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if(!p_getc(&temp_zinit.ene_damage_multiplier,f))
20756 return qe_invalid;
20757
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if(!p_getc(&temp_zinit.dither_type,f))
20758 return qe_invalid;
20759
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if(!p_getc(&temp_zinit.dither_arg,f))
20760 return qe_invalid;
20761
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if(!p_getc(&temp_zinit.dither_percent,f))
20762 return qe_invalid;
20763
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if(!p_getc(&temp_zinit.def_lightrad,f))
20764 return qe_invalid;
20765
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if(!p_getc(&temp_zinit.transdark_percent,f))
20766 return qe_invalid;
20767
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if(!p_getc(&temp_zinit.darkcol,f))
20768 return qe_invalid;
20769
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if(!p_igetl(&temp_zinit.ss_grid_x,f))
20770 return qe_invalid;
20771
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if(!p_igetl(&temp_zinit.ss_grid_y,f))
20772 return qe_invalid;
20773
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if(!p_igetl(&temp_zinit.ss_grid_xofs,f))
20774 return qe_invalid;
20775
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if(!p_igetl(&temp_zinit.ss_grid_yofs,f))
20776 return qe_invalid;
20777
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if(!p_igetl(&temp_zinit.ss_grid_color,f))
20778 return qe_invalid;
20779
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if(!p_igetl(&temp_zinit.ss_bbox_1_color,f))
20780 return qe_invalid;
20781
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if(!p_igetl(&temp_zinit.ss_bbox_2_color,f))
20782 return qe_invalid;
20783
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if(!p_igetl(&temp_zinit.ss_flags,f))
20784 return qe_invalid;
20785
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if(!p_getbitstr(&temp_zinit.flags,f))
20786 return qe_invalid;
20787
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if(!p_getc(&temp_zinit.last_map,f))
20788 return qe_invalid;
20789
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if(!p_getc(&temp_zinit.last_screen,f))
20790 return qe_invalid;
20791
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if(!p_getc(&temp_zinit.msg_more_x,f))
20792 return qe_invalid;
20793
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if(!p_getc(&temp_zinit.msg_more_y,f))
20794 return qe_invalid;
20795
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if(!p_getc(&temp_zinit.msg_more_is_offset,f))
20796 return qe_invalid;
20797
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if(!p_getc(&temp_zinit.msg_speed,f))
20798 return qe_invalid;
20799
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if(!p_igetl(&temp_zinit.gravity,f))
20800 return qe_invalid;
20801
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if(!p_igetl(&temp_zinit.swimgravity,f))
20802 return qe_invalid;
20803
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if(!p_igetw(&temp_zinit.terminalv,f))
20804 return qe_invalid;
20805
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if(!p_getc(&temp_zinit.hero_swim_speed,f))
20806 return qe_invalid;
20807
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if(!p_getc(&temp_zinit.hero_swim_mult,f))
20808 return qe_invalid;
20809
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if(!p_getc(&temp_zinit.hero_swim_div,f))
20810 return qe_invalid;
20811
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if(!p_igetw(&temp_zinit.heroSideswimUpStep,f))
20812 return qe_invalid;
20813
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if(!p_igetw(&temp_zinit.heroSideswimSideStep,f))
20814 return qe_invalid;
20815
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if(!p_igetw(&temp_zinit.heroSideswimDownStep,f))
20816 return qe_invalid;
20817
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if(!p_igetl(&temp_zinit.exitWaterJump,f))
20818 return qe_invalid;
20819
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if(!p_igetw(&temp_zinit.heroStep,f))
20820 return qe_invalid;
20821
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if(!p_getc(&temp_zinit.heroAnimationStyle,f))
20822 return qe_invalid;
20823
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if(!p_getc(&temp_zinit.jump_hero_layer_threshold,f))
20824 return qe_invalid;
20825
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if(!p_igetl(&temp_zinit.bunny_ltm,f))
20826 return qe_invalid;
20827
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if(!p_igetw(&temp_zinit.start_dmap,f))
20828 return qe_invalid;
20829
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if(!p_igetw(&temp_zinit.subscrSpeed,f))
20830 return qe_invalid;
20831
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if(!p_getc(&temp_zinit.switchhookstyle,f))
20832 return qe_invalid;
20833
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if(!p_getc(&temp_zinit.magicdrainrate,f))
20834 return qe_invalid;
20835
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if(!p_igetzf(&temp_zinit.shove_offset,f))
20836 return qe_invalid;
20837
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if(!p_getbitstr(&temp_zinit.gen_doscript, f))
20838 return qe_invalid;
20839
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if(!p_getbmap(&temp_zinit.gen_exitState, f))
20840 return qe_invalid;
20841
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if(!p_getbmap(&temp_zinit.gen_reloadState, f))
20842 return qe_invalid;
20843
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if(!p_getbmap(&temp_zinit.gen_initd, f))
20844 return qe_invalid;
20845
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if(!p_getbmap(&temp_zinit.gen_eventstate, f))
20846 return qe_invalid;
20847
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if(!p_getbmap(&temp_zinit.gen_data, f))
20848 return qe_invalid;
20849
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if(!p_getbmap(&temp_zinit.screen_data, f))
20850 return qe_invalid;
20851
1/2
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
376 if (s_version >= 38)
20852 {
20853
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if (!p_getc(&temp_zinit.spriteflickerspeed, f))
20854 return qe_invalid;
20855
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if (!p_getc(&temp_zinit.spriteflickercolor, f))
20856 return qe_invalid;
20857
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if (!p_getc(&temp_zinit.spriteflickertransp, f))
20858 return qe_invalid;
20859 376 }
20860
2/2
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 274 times.
376 if(s_version >= 39)
20861
2/4
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102 times.
✗ Branch 3 not taken.
102 if(!p_igetzf(&temp_zinit.air_drag, f))
20862 return qe_invalid;
20863 }
20864
1/2
✓ Branch 0 taken 588 times.
✗ Branch 1 not taken.
588 if (should_skip)
20865 return 0;
20866
20867
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 588 times.
588 if(loading_tileset_flags & TILESET_CLEARMAPS)
20868 {
20869 temp_zinit.last_map = 0;
20870 temp_zinit.last_screen = 0;
20871 temp_zinit.screen_data.clear();
20872 }
20873
1/2
✓ Branch 0 taken 588 times.
✗ Branch 1 not taken.
588 temp_zinit.normalize();
20874
1/2
✓ Branch 0 taken 588 times.
✗ Branch 1 not taken.
588 zinit = temp_zinit;
20875
20876
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 588 times.
588 if(zinit.heroAnimationStyle==las_zelda3slow)
20877 {
20878 hero_animation_speed=2;
20879 }
20880 else
20881 {
20882 588 hero_animation_speed=1;
20883 }
20884
20885 588 return 0;
20886 588 }
20887
20888 /*
20889 void setupitemdropsets()
20890 {
20891 for(int32_t i=0; i<isMAX; i++)
20892 {
20893 memcpy(&item_drop_sets[i], &default_item_drop_sets[i], sizeof(item_drop_object));
20894 }
20895 }
20896 */
20897
20898 549 int32_t readitemdropsets(PACKFILE *f, int32_t version, word build)
20899 {
20900
2/2
✓ Branch 0 taken 526 times.
✓ Branch 1 taken 23 times.
549 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_itemdropsets);
20901
20902 549 build=build; // here to prevent compiler warnings
20903 dword dummy_dword;
20904 549 word item_drop_sets_to_read=0;
20905 item_drop_object tempitemdrop;
20906 549 word s_version=0, s_cversion=0;
20907
20908
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 549 times.
549 if (!should_skip)
20909
2/2
✓ Branch 0 taken 140544 times.
✓ Branch 1 taken 549 times.
141093 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
20910 {
20911 140544 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
20912 141093 }
20913
20914
2/2
✓ Branch 0 taken 526 times.
✓ Branch 1 taken 23 times.
549 if(version > 0x192)
20915 {
20916 526 item_drop_sets_to_read=0;
20917
20918 //section version info
20919
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 if(!p_igetw(&s_version,f))
20920 {
20921 return qe_invalid;
20922 }
20923
20924 526 FFCore.quest_format[vItemDropsets] = s_version;
20925
20926 //al_trace("Item drop sets version %d\n", s_version);
20927
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 if(!p_igetw(&s_cversion,f))
20928 {
20929 return qe_invalid;
20930 }
20931
20932 //section size
20933
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 if(!p_igetl(&dummy_dword,f))
20934 {
20935 return qe_invalid;
20936 }
20937
20938 //finally... section data
20939
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 if(!p_igetw(&item_drop_sets_to_read,f))
20940 {
20941 return qe_invalid;
20942 }
20943
20944
2/4
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 526 times.
✗ Branch 3 not taken.
526 if (!(item_drop_sets_to_read >= 0 && item_drop_sets_to_read <= MAXITEMDROPSETS))
20945 {
20946 return qe_invalid;
20947 }
20948 526 }
20949 else
20950 {
20951 23 init_item_drop_sets();
20952 }
20953
20954
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 526 times.
549 if(s_version>=1)
20955 {
20956
2/2
✓ Branch 0 taken 7566 times.
✓ Branch 1 taken 526 times.
8092 for(int32_t i=0; i<item_drop_sets_to_read; i++)
20957 {
20958
1/2
✓ Branch 0 taken 7566 times.
✗ Branch 1 not taken.
7566 if(!p_getstr(tempitemdrop.name,sizeof(tempitemdrop.name)-1,f))
20959 {
20960 return qe_invalid;
20961 }
20962
20963
2/2
✓ Branch 0 taken 75660 times.
✓ Branch 1 taken 7566 times.
83226 for(int32_t j=0; j<10; ++j)
20964 {
20965
1/2
✓ Branch 0 taken 75660 times.
✗ Branch 1 not taken.
75660 if(!p_igetw(&tempitemdrop.item[j],f))
20966 {
20967 return qe_invalid;
20968 }
20969 75660 }
20970
20971
2/2
✓ Branch 0 taken 83226 times.
✓ Branch 1 taken 7566 times.
90792 for(int32_t j=0; j<11; ++j)
20972 {
20973
1/2
✓ Branch 0 taken 83226 times.
✗ Branch 1 not taken.
83226 if(!p_igetw(&tempitemdrop.chance[j],f))
20974 {
20975 return qe_invalid;
20976 }
20977 83226 }
20978
20979 // Dec 2008: Addition of the 'Tall Grass' set, #12,
20980 // overrides the quest's set #12.
20981
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7566 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7566 if(s_version<2 && i==12)
20982 continue;
20983
20984 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
20985
1/4
✓ Branch 0 taken 7566 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7566 if(s_version<2) for(int32_t j=0; j<10; ++j)
20986 {
20987 int32_t it = tempitemdrop.item[j];
20988
20989 if((itemsbuf[it].family == itype_rupee
20990 && ((itemsbuf[it].amount)&0xFFF) == 10)
20991 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
20992 {
20993 tempitemdrop.chance[j+1]=0;
20994 }
20995 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
20996 {
20997 tempitemdrop.chance[j+1]=0;
20998 }
20999
21000 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
21001 if(itemsbuf[it].family == itype_misc)
21002 {
21003 // If a non-gameplay item was selected, then item drop was aborted.
21004 // Reflect this by increasing the 'Nothing' chance accordingly.
21005 tempitemdrop.chance[0]+=tempitemdrop.chance[j+1];
21006 tempitemdrop.chance[j+1]=0;
21007 }
21008 }
21009
21010
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7566 times.
7566 if (!should_skip)
21011 7566 memcpy(&item_drop_sets[i], &tempitemdrop, sizeof(item_drop_object));
21012 7566 }
21013 526 }
21014
21015 549 return 0;
21016 549 }
21017
21018 526 int32_t readfavorites(PACKFILE *f, int32_t, word)
21019 {
21020
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_favorites);
21021
21022 int32_t temp_num;
21023 dword dummy_dword;
21024 word num_favorite_combos;
21025 word num_favorite_combo_aliases;
21026 526 word s_version=0, s_cversion=0;
21027
21028 //section version info
21029
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 if(!p_igetw(&s_version,f))
21030 {
21031 return qe_invalid;
21032 }
21033
21034
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 526 times.
526 if (!should_skip)
21035 526 FFCore.quest_format[vFavourites] = s_version;
21036
21037
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 if(!p_igetw(&s_cversion,f))
21038 {
21039 return qe_invalid;
21040 }
21041
21042 //section size
21043
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 if(!p_igetl(&dummy_dword,f))
21044 {
21045 return qe_invalid;
21046 }
21047
21048 526 word per_row = FAVORITECOMBO_PER_ROW;
21049 526 word per_page = FAVORITECOMBO_PER_PAGE;
21050
2/2
✓ Branch 0 taken 143 times.
✓ Branch 1 taken 383 times.
526 if(s_version >= 3)
21051
1/2
✓ Branch 0 taken 383 times.
✗ Branch 1 not taken.
383 if(!p_igetw(&per_row,f))
21052 return qe_invalid;
21053
2/2
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 376 times.
526 if(s_version >= 4)
21054
1/2
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
376 if(!p_igetw(&per_page,f))
21055 return qe_invalid;
21056 //finally... section data
21057
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 if(!p_igetw(&num_favorite_combos,f))
21058 {
21059 return qe_invalid;
21060 }
21061
21062 //Hack; port old favorite combos
21063
3/4
✓ Branch 0 taken 143 times.
✓ Branch 1 taken 383 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 143 times.
526 if(s_version < 3 && num_favorite_combos == 100)
21064 143 per_row = 13;
21065
21066
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 526 times.
526 if (!should_skip)
21067
2/2
✓ Branch 0 taken 662760 times.
✓ Branch 1 taken 526 times.
663286 for(int q = 0; q < MAXFAVORITECOMBOS; ++q)
21068 663286 favorite_combos[q] = -1;
21069 526 byte favtype = 0;
21070
2/2
✓ Branch 0 taken 54586 times.
✓ Branch 1 taken 526 times.
55112 for(int32_t i=0; i<num_favorite_combos; i++)
21071 {
21072
2/2
✓ Branch 0 taken 40279 times.
✓ Branch 1 taken 14307 times.
54586 if (s_version >= 4)
21073 {
21074
1/2
✓ Branch 0 taken 40279 times.
✗ Branch 1 not taken.
40279 if (!p_getc(&favtype, f))
21075 {
21076 return qe_invalid;
21077 }
21078 40279 }
21079 else
21080 14307 favtype = 0;
21081
1/2
✓ Branch 0 taken 54586 times.
✗ Branch 1 not taken.
54586 if(!p_igetl(&temp_num,f))
21082 {
21083 return qe_invalid;
21084 }
21085
21086
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 54586 times.
54586 if (should_skip)
21087 continue;
21088
21089
2/2
✓ Branch 0 taken 40279 times.
✓ Branch 1 taken 14307 times.
54586 if(per_row == FAVORITECOMBO_PER_ROW)
21090 {
21091 40279 favorite_combos[i] = temp_num;
21092 40279 favorite_combo_modes[i] = favtype;
21093 40279 }
21094 else
21095 {
21096 14307 int new_i = (i%per_row) + (i/per_row)*FAVORITECOMBO_PER_ROW;
21097 14307 favorite_combos[new_i]=temp_num;
21098 14307 favorite_combo_modes[new_i] = favtype;
21099 }
21100 54586 }
21101
21102 // Discard the separate favorite aliases list from previous versions
21103
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 150 times.
526 if(s_version<4)
21104 {
21105
1/2
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
150 if (!p_igetw(&num_favorite_combo_aliases, f))
21106 {
21107 return qe_invalid;
21108 }
21109
21110
2/2
✓ Branch 0 taken 14300 times.
✓ Branch 1 taken 150 times.
14450 for (int32_t i = 0; i < num_favorite_combo_aliases; i++)
21111 {
21112
1/2
✓ Branch 0 taken 14300 times.
✗ Branch 1 not taken.
14300 if (!p_igetl(&temp_num, f))
21113 {
21114 return qe_invalid;
21115 }
21116 14300 }
21117 150 }
21118
21119 526 word max_combo_cols = 0;
21120 526 word max_mappages = 0;
21121
2/2
✓ Branch 0 taken 143 times.
✓ Branch 1 taken 383 times.
526 if(s_version >= 2)
21122 {
21123
1/2
✓ Branch 0 taken 383 times.
✗ Branch 1 not taken.
383 if(!p_igetw(&max_combo_cols,f))
21124 return qe_invalid;
21125 383 int32_t tmp = 0, tmp2 = 0, tmp3 = 0;
21126
2/2
✓ Branch 0 taken 1532 times.
✓ Branch 1 taken 383 times.
1915 for(int q = 0; q < max_combo_cols; ++q)
21127 {
21128
1/2
✓ Branch 0 taken 1532 times.
✗ Branch 1 not taken.
1532 if(!p_igetl(&tmp,f))
21129 return qe_invalid;
21130
1/2
✓ Branch 0 taken 1532 times.
✗ Branch 1 not taken.
1532 if(!p_igetl(&tmp2,f))
21131 return qe_invalid;
21132
1/2
✓ Branch 0 taken 1532 times.
✗ Branch 1 not taken.
1532 if(!p_igetl(&tmp3,f))
21133 return qe_invalid;
21134
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1532 times.
1532 if(q < MAX_COMBO_COLS)
21135 {
21136 1532 First[q] = tmp;
21137 1532 combo_alistpos[q] = tmp2;
21138 1532 combo_pool_listpos[q] = tmp3;
21139 1532 }
21140 1532 }
21141
21142
1/2
✓ Branch 0 taken 383 times.
✗ Branch 1 not taken.
383 if(!p_igetw(&max_mappages,f))
21143 return qe_invalid;
21144
2/2
✓ Branch 0 taken 3447 times.
✓ Branch 1 taken 383 times.
3830 for(int q = 0; q < max_mappages; ++q)
21145 {
21146
1/2
✓ Branch 0 taken 3447 times.
✗ Branch 1 not taken.
3447 if(!p_igetl(&tmp,f))
21147 return qe_invalid;
21148
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3447 times.
3447 if(!p_igetl(&tmp2,f))
21149 return qe_invalid;
21150
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3447 times.
3447 if(q < MAX_MAPPAGE_BTNS)
21151 {
21152 3447 map_page[q].map = tmp;
21153 3447 map_page[q].screen = tmp2;
21154 3447 }
21155 3447 }
21156 383 }
21157
21158
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 526 times.
526 if (should_skip)
21159 return 0;
21160
21161
2/2
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 526 times.
1098 for(int q = max_combo_cols; q < MAX_COMBO_COLS; ++q)
21162 {
21163 572 First[q] = 0;
21164 572 combo_alistpos[q] = 0;
21165 572 combo_pool_listpos[q] = 0;
21166 572 }
21167
2/2
✓ Branch 0 taken 1287 times.
✓ Branch 1 taken 526 times.
1813 for(int q = max_mappages; q < MAX_MAPPAGE_BTNS; ++q)
21168 {
21169 1287 map_page[q].map = 0;
21170 1287 map_page[q].screen = 0;
21171 1287 }
21172
21173 526 return 0;
21174 526 }
21175
21176 /*
21177 switch (ret) {
21178 case 0:
21179 break;
21180
21181 case qe_invalid:
21182 goto invalid;
21183 break;
21184 default:
21185 pack_fclose(f);
21186 if(!oldquest)
21187 delete_file(tmpfilename);
21188 return ret;
21189 break;
21190 }
21191 */
21192
21193 const char *skip_text[skip_max]=
21194 {
21195 "skip_header", "skip_rules", "skip_strings", "skip_misc",
21196 "skip_tiles", "skip_combos", "skip_comboaliases", "skip_csets",
21197 "skip_maps", "skip_dmaps", "skip_doors", "skip_items",
21198 "skip_weapons", "skip_colors", "skip_icons", "skip_initdata",
21199 "skip_guys", "skip_herosprites", "skip_subscreens", "skip_ffscript",
21200 "skip_sfx", "skip_midis", "skip_cheats", "skip_itemdropsets",
21201 "skip_favorites"
21202 };
21203
21204
21205 void port250QuestRules(){
21206
21207 portCandleRules(); //Candle
21208 portBombRules();
21209
21210 }
21211
21212 void portCandleRules()
21213 {
21214 bool hurtshero = get_qr(qr_FIREPROOFHERO);
21215 //itemdata itemsbuf;
21216 for ( int32_t q = 0; q < MAXITEMS; q++ )
21217 {
21218 if ( itemsbuf[q].family == itype_candle )
21219 {
21220 if ( hurtshero ) itemsbuf[q].flags |= ITEM_FLAG2;
21221 else itemsbuf[q].flags &= ~ ITEM_FLAG2;
21222 }
21223 }
21224 }
21225
21226 void portBombRules()
21227 {
21228 bool hurtshero = get_qr(qr_OUCHBOMBS);
21229 //itemdata itemsbuf;
21230 for ( int32_t q = 0; q < MAXITEMS; q++ )
21231 {
21232 if ( itemsbuf[q].family == itype_bomb )
21233 {
21234 if ( hurtshero ) itemsbuf[q].flags |= ITEM_FLAG2;
21235 else itemsbuf[q].flags &= ~ ITEM_FLAG2;
21236 }
21237 }
21238 }
21239
21240 13617 static int section_id_to_enum(int id)
21241 {
21242
24/27
✗ Branch 0 not taken.
✓ Branch 1 taken 589 times.
✓ Branch 2 taken 589 times.
✓ Branch 3 taken 589 times.
✓ Branch 4 taken 589 times.
✓ Branch 5 taken 589 times.
✓ Branch 6 taken 526 times.
✓ Branch 7 taken 589 times.
✓ Branch 8 taken 589 times.
✓ Branch 9 taken 589 times.
✓ Branch 10 taken 589 times.
✓ Branch 11 taken 589 times.
✓ Branch 12 taken 589 times.
✓ Branch 13 taken 526 times.
✓ Branch 14 taken 526 times.
✓ Branch 15 taken 589 times.
✓ Branch 16 taken 589 times.
✓ Branch 17 taken 550 times.
✓ Branch 18 taken 526 times.
✓ Branch 19 taken 526 times.
✓ Branch 20 taken 526 times.
✓ Branch 21 taken 589 times.
✓ Branch 22 taken 589 times.
✓ Branch 23 taken 550 times.
✓ Branch 24 taken 526 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
13617 switch (id)
21243 {
21244 case ID_HEADER: return skip_header;
21245 589 case ID_RULES: return skip_rules;
21246 589 case ID_STRINGS: return skip_strings;
21247 589 case ID_MISC: return skip_misc;
21248 589 case ID_TILES: return skip_tiles;
21249 589 case ID_COMBOS: return skip_combos;
21250 526 case ID_COMBOALIASES: return skip_comboaliases;
21251 589 case ID_CSETS: return skip_csets;
21252 589 case ID_MAPS: return skip_maps;
21253 589 case ID_DMAPS: return skip_dmaps;
21254 589 case ID_DOORS: return skip_doors;
21255 589 case ID_ITEMS: return skip_items;
21256 589 case ID_WEAPONS: return skip_weapons;
21257 526 case ID_COLORS: return skip_colors;
21258 526 case ID_ICONS: return skip_icons;
21259 589 case ID_INITDATA: return skip_initdata;
21260 589 case ID_GUYS: return skip_guys;
21261 550 case ID_HEROSPRITES: return skip_herosprites;
21262 526 case ID_SUBSCREEN: return skip_subscreens;
21263 526 case ID_FFSCRIPT: return skip_ffscript;
21264 526 case ID_SFX: return skip_sfx;
21265 589 case ID_MIDIS: return skip_midis;
21266 589 case ID_CHEATS: return skip_cheats;
21267 550 case ID_ITEMDROPSETS: return skip_itemdropsets;
21268 526 case ID_FAVORITES: return skip_favorites;
21269 case ID_ZINFO: return skip_zinfo;
21270 }
21271
21272 return -1;
21273 13617 }
21274
21275 13209 static int maybe_skip_section(PACKFILE* f, dword& section_id, const byte* skip_flags)
21276 {
21277 13209 int section_enum = section_id_to_enum(section_id);
21278
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13209 times.
13209 bool skip = section_enum >= 0 && get_bit(skip_flags, section_enum);
21279
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13209 times.
13209 if (skip)
21280 {
21281 word s_version;
21282 if (!p_igetw(&s_version,f))
21283 {
21284 return qe_invalid;
21285 }
21286
21287 word c_version;
21288 if (!p_igetw(&c_version,f))
21289 {
21290 return qe_invalid;
21291 }
21292
21293 if (section_id == ID_RULES && s_version > 16)
21294 {
21295 dword dummy;
21296 if (!p_igetl(&dummy,f))
21297 {
21298 return qe_invalid;
21299 }
21300 }
21301
21302 if (section_id == ID_FFSCRIPT && s_version >= 18)
21303 {
21304 word dummy;
21305 if (!p_igetw(&dummy,f))
21306 {
21307 return qe_invalid;
21308 }
21309 }
21310
21311 dword section_length;
21312 if (!p_igetl(&section_length,f))
21313 {
21314 return qe_invalid;
21315 }
21316
21317 if (pack_fseek(f, section_length))
21318 {
21319 return qe_invalid;
21320 }
21321
21322 if (!pack_feof(f))
21323 {
21324 if (!p_mgetl(&section_id,f))
21325 {
21326 return qe_invalid;
21327 }
21328 }
21329
21330 return qe_cancel;
21331 }
21332
21333 13209 return qe_OK;
21334 13209 }
21335
21336 //Internal function for loadquest wrapper
21337 589 static int32_t _lq_int(const char *filename, zquestheader *Header, miscQdata *Misc, zctune *tunes, bool show_progress, byte *skip_flags, byte printmetadata)
21338 {
21339 589 DMapEditorLastMaptileUsed = 0;
21340 589 combosread=false;
21341 589 mapsread=false;
21342 589 fixffcs=false;
21343
21344 589 bool do_clear_scripts = !get_bit(skip_flags,skip_ffscript);
21345
1/2
✓ Branch 0 taken 589 times.
✗ Branch 1 not taken.
589 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
21346 {
21347 set_bit(skip_flags, skip_ffscript, 1);
21348 setZScriptVersion(V_FFSCRIPT);
21349 FFCore.quest_format[vFFScript] = V_FFSCRIPT;
21350 FFCore.quest_format[vLastCompile] = V_FFSCRIPT;
21351 do_clear_scripts = true;
21352 }
21353
1/2
✓ Branch 0 taken 589 times.
✗ Branch 1 not taken.
589 if(loading_tileset_flags & TILESET_CLEARMAPS)
21354 {
21355 set_bit(skip_flags, skip_maps, 1);
21356 }
21357
21358 // show_progress=true;
21359 char tmpfilename[L_tmpnam];
21360 589 temp_name(tmpfilename);
21361 // char percent_done[30];
21362 589 bool catchup=false;
21363 byte tempbyte;
21364 589 word old_map_count=map_count;
21365
21366 589 byte old_quest_rules[QUESTRULES_NEW_SIZE] = {0};
21367 589 byte old_extra_rules[EXTRARULES_SIZE] = {0};
21368 589 byte old_midi_flags[MIDIFLAGS_SIZE] = {0};
21369
21370
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 588 times.
589 if(get_bit(skip_flags, skip_rules))
21371 {
21372 1 memcpy(old_quest_rules, quest_rules, QUESTRULES_NEW_SIZE);
21373 1 memcpy(old_extra_rules, extra_rules, EXTRARULES_SIZE);
21374 1 }
21375
21376 589 memset(quest_rules, 0, QUESTRULES_NEW_SIZE); //clear here to prevent any kind of carryover -Z
21377 589 unpack_qrs();
21378 // memset(extra_rules, 0, EXTRARULES_SIZE); //clear here to prevent any kind of carryover -Z
21379
21380
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 588 times.
589 if(get_bit(skip_flags, skip_midis))
21381 {
21382 1 memcpy(old_midi_flags, midi_flags, MIDIFLAGS_SIZE);
21383 1 }
21384
21385
21386
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 588 times.
589 if(do_clear_scripts)
21387 {
21388 588 zScript.clear();
21389 588 globalmap.clear();
21390 588 genericmap.clear();
21391 588 ffcmap.clear();
21392 588 itemmap.clear();
21393 588 npcmap.clear();
21394 588 ewpnmap.clear();
21395 588 lwpnmap.clear();
21396 588 playermap.clear();
21397 588 dmapmap.clear();
21398 588 screenmap.clear();
21399 588 itemspritemap.clear();
21400 588 comboscriptmap.clear();
21401 588 subscreenmap.clear();
21402
21403
2/2
✓ Branch 0 taken 300468 times.
✓ Branch 1 taken 588 times.
301056 for(int32_t i=0; i<NUMSCRIPTFFC-1; i++)
21404 {
21405 300468 ffcmap[i].clear();
21406 300468 }
21407
21408 588 globalmap[0].slotname = "Slot 1:";
21409 588 globalmap[0].scriptname = "~Init";
21410 588 globalmap[0].update();
21411
21412
2/2
✓ Branch 0 taken 4116 times.
✓ Branch 1 taken 588 times.
4704 for(int32_t i=1; i<NUMSCRIPTGLOBAL; i++)
21413 {
21414 4116 globalmap[i].clear();
21415 4116 }
21416
21417
2/2
✓ Branch 0 taken 149940 times.
✓ Branch 1 taken 588 times.
150528 for(int32_t i=0; i<NUMSCRIPTITEM-1; i++)
21418 {
21419 149940 itemmap[i].clear();
21420 149940 }
21421
21422 //new script types -- prevent carrying over to a quest that you load after reading them
21423 //e.g., a quest has an npc script, and you make a blank quest, that now believes that it has an npc script, too!
21424
2/2
✓ Branch 0 taken 149940 times.
✓ Branch 1 taken 588 times.
150528 for(int32_t i=0; i<NUMSCRIPTGUYS-1; i++)
21425 {
21426 149940 npcmap[i].clear();
21427 149940 }
21428
2/2
✓ Branch 0 taken 149940 times.
✓ Branch 1 taken 588 times.
150528 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21429 {
21430 149940 lwpnmap[i].clear();
21431 149940 }
21432
2/2
✓ Branch 0 taken 149940 times.
✓ Branch 1 taken 588 times.
150528 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21433 {
21434 149940 ewpnmap[i].clear();
21435 149940 }
21436
2/2
✓ Branch 0 taken 2352 times.
✓ Branch 1 taken 588 times.
2940 for(int32_t i=0; i<NUMSCRIPTPLAYER-1; i++)
21437 {
21438 2352 playermap[i].clear();
21439 2352 }
21440
2/2
✓ Branch 0 taken 149940 times.
✓ Branch 1 taken 588 times.
150528 for(int32_t i=0; i<NUMSCRIPTSDMAP-1; i++)
21441 {
21442 149940 dmapmap[i].clear();
21443 149940 }
21444
2/2
✓ Branch 0 taken 149940 times.
✓ Branch 1 taken 588 times.
150528 for(int32_t i=0; i<NUMSCRIPTSCREEN-1; i++)
21445 {
21446 149940 screenmap[i].clear();
21447 149940 }
21448
2/2
✓ Branch 0 taken 149940 times.
✓ Branch 1 taken 588 times.
150528 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE-1; i++)
21449 {
21450 149940 itemspritemap[i].clear();
21451 149940 }
21452
2/2
✓ Branch 0 taken 300468 times.
✓ Branch 1 taken 588 times.
301056 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA-1; i++)
21453 {
21454 300468 comboscriptmap[i].clear();
21455 300468 }
21456
2/2
✓ Branch 0 taken 300468 times.
✓ Branch 1 taken 588 times.
301056 for(int32_t i=0; i<NUMSCRIPTSGENERIC-1; i++)
21457 {
21458 300468 genericmap[i].clear();
21459 300468 }
21460
2/2
✓ Branch 0 taken 149940 times.
✓ Branch 1 taken 588 times.
150528 for(int32_t i=0; i<NUMSCRIPTSSUBSCREEN-1; i++)
21461 {
21462 149940 subscreenmap[i].clear();
21463 149940 }
21464
21465 588 reset_scripts();
21466 588 }
21467
21468 zquestheader tempheader;
21469 589 memset(&tempheader, 0, sizeof(zquestheader));
21470 589 zinfo tempzi;
21471 589 tempzi.clear();
21472 589 load_tmp_zi = &tempzi;
21473
21474 // oldquest flag is set when an unencrypted qst file is suspected.
21475 589 bool oldquest = false;
21476 589 int32_t open_error=0;
21477 589 PACKFILE *f=open_quest_file(&open_error, filename, show_progress);
21478
21479
1/2
✓ Branch 0 taken 589 times.
✗ Branch 1 not taken.
589 if (!f)
21480 {
21481 ASSERT(open_error != 0);
21482 return open_error;
21483 }
21484 char zinfofilename[2048];
21485 589 replace_extension(zinfofilename, filename, "zinfo", 2047);
21486 589 int32_t ret=0;
21487
21488 //header
21489 589 box_out("Reading Header...");
21490 589 ret=readheader(f, &tempheader, printmetadata);
21491
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 589 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
589 checkstatus(ret);
21492 589 box_out("okay.");
21493 589 box_eol();
21494
21495
2/2
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 394 times.
589 if(read_zinfo)
21496 {
21497 394 box_out("Reading ZInfo - ");
21498
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 391 times.
394 box_out(read_ext_zinfo ? "External..." : "Internal...");
21499
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 391 times.
394 if(read_ext_zinfo)
21500 {
21501 3 PACKFILE *inf=pack_fopen_password(zinfofilename, F_READ, "");
21502 3 ret=readzinfo(inf, tempzi, tempheader);
21503
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(inf) pack_fclose(inf);
21504
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
3 checkstatus(ret);
21505 3 }
21506 else
21507 {
21508 391 ret=readzinfo(f, tempzi, tempheader);
21509
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 391 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
391 checkstatus(ret);
21510 }
21511 394 box_out("okay.");
21512 394 box_eol();
21513 394 }
21514
21515
2/2
✓ Branch 0 taken 565 times.
✓ Branch 1 taken 24 times.
589 if(tempheader.zelda_version>=0x193)
21516 {
21517 dword section_id;
21518
21519 //section id
21520
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 if(!p_mgetl(&section_id,f))
21521 {
21522 goto invalid;
21523 }
21524
21525 565 std::set<dword> seen_sections;
21526
21527
3/4
✓ Branch 0 taken 13774 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13209 times.
✓ Branch 3 taken 565 times.
13774 while(!pack_feof(f))
21528 {
21529
2/4
✓ Branch 0 taken 13209 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13209 times.
✗ Branch 3 not taken.
13209 if (seen_sections.contains(section_id))
21530 goto invalid;
21531
1/2
✓ Branch 0 taken 13209 times.
✗ Branch 1 not taken.
13209 seen_sections.insert(section_id);
21532
21533
2/4
✓ Branch 0 taken 13209 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13209 times.
✗ Branch 3 not taken.
13209 if (int retval = maybe_skip_section(f, section_id, skip_flags); retval != qe_OK)
21534 {
21535 if (retval == qe_cancel)
21536 continue;
21537 checkstatus(retval);
21538 }
21539
21540
24/25
✓ Branch 0 taken 565 times.
✓ Branch 1 taken 565 times.
✓ Branch 2 taken 565 times.
✓ Branch 3 taken 565 times.
✓ Branch 4 taken 565 times.
✓ Branch 5 taken 526 times.
✓ Branch 6 taken 565 times.
✓ Branch 7 taken 565 times.
✓ Branch 8 taken 565 times.
✓ Branch 9 taken 565 times.
✓ Branch 10 taken 565 times.
✓ Branch 11 taken 565 times.
✓ Branch 12 taken 526 times.
✓ Branch 13 taken 526 times.
✓ Branch 14 taken 565 times.
✓ Branch 15 taken 565 times.
✓ Branch 16 taken 526 times.
✓ Branch 17 taken 526 times.
✓ Branch 18 taken 526 times.
✓ Branch 19 taken 526 times.
✓ Branch 20 taken 565 times.
✓ Branch 21 taken 565 times.
✓ Branch 22 taken 526 times.
✓ Branch 23 taken 526 times.
✗ Branch 24 not taken.
13209 switch(section_id)
21541 {
21542 case ID_RULES:
21543
21544 //rules
21545
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 565 times.
565 if(catchup)
21546 {
21547 box_out("found.");
21548 box_eol();
21549 catchup=false;
21550 }
21551
21552
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 box_out("Reading Rules...");
21553
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 ret=readrules(f, &tempheader);
21554
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 565 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
565 checkstatus(ret);
21555
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 box_out("okay.");
21556
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 box_eol();
21557 565 break;
21558
21559 case ID_STRINGS:
21560
21561 //strings
21562
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 565 times.
565 if(catchup)
21563 {
21564 box_out("found.");
21565 box_eol();
21566 catchup=false;
21567 }
21568
21569
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 box_out("Reading Strings...");
21570
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 ret=readstrings(f, &tempheader);
21571
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 565 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
565 checkstatus(ret);
21572
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 box_out("okay.");
21573
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 box_eol();
21574 565 break;
21575
21576 case ID_MISC:
21577
21578 //misc data
21579
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 565 times.
565 if(catchup)
21580 {
21581 box_out("found.");
21582 box_eol();
21583 catchup=false;
21584 }
21585
21586
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 box_out("Reading Misc. Data...");
21587
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 ret=readmisc(f, &tempheader, Misc);
21588
1/9
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
565 checkstatus(ret);
21589
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 box_out("okay.");
21590
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 box_eol();
21591 565 break;
21592
21593 case ID_TILES:
21594
21595 //tiles
21596
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 565 times.
565 if(catchup)
21597 {
21598 box_out("found.");
21599 box_eol();
21600 catchup=false;
21601 }
21602
21603
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 box_out("Reading Tiles...");
21604
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 ret=readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false);
21605
1/9
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
565 checkstatus(ret);
21606
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 box_out("okay.");
21607
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 box_eol();
21608 565 break;
21609
21610 case ID_COMBOS:
21611
21612 //combos
21613
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 565 times.
565 if(catchup)
21614 {
21615 box_out("found.");
21616 box_eol();
21617 catchup=false;
21618 }
21619
21620
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 box_out("Reading Combos...");
21621
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 ret=readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS);
21622 565 combosread=true;
21623
1/9
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
565 checkstatus(ret);
21624
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 box_out("okay.");
21625
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 box_eol();
21626 565 break;
21627
21628 case ID_COMBOALIASES:
21629
21630 //combo aliases
21631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 526 times.
526 if(catchup)
21632 {
21633 box_out("found.");
21634 box_eol();
21635 catchup=false;
21636 }
21637
21638
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 box_out("Reading Combo Aliases...");
21639
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 ret=readcomboaliases(f, &tempheader, tempheader.zelda_version, tempheader.build);
21640
1/9
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
526 checkstatus(ret);
21641
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 box_out("okay.");
21642
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 box_eol();
21643 526 break;
21644
21645 case ID_CSETS:
21646
21647 //color data
21648
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 565 times.
565 if(catchup)
21649 {
21650 box_out("found.");
21651 box_eol();
21652 catchup=false;
21653 }
21654
21655
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 box_out("Reading Color Data...");
21656
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 ret=readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL);
21657
1/9
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
565 checkstatus(ret);
21658
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 box_out("okay.");
21659
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 box_eol();
21660 565 break;
21661
21662 case ID_MAPS:
21663
21664 //maps
21665
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 565 times.
565 if(catchup)
21666 {
21667 box_out("found.");
21668 box_eol();
21669 catchup=false;
21670 }
21671
21672
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 box_out("Reading Maps...");
21673
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 ret=readmaps(f, &tempheader);
21674 565 mapsread=true;
21675
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 565 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
565 checkstatus(ret);
21676
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 box_out("okay.");
21677
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 box_eol();
21678 565 break;
21679
21680 case ID_DMAPS:
21681
21682 //dmaps
21683
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 565 times.
565 if(catchup)
21684 {
21685 box_out("found.");
21686 box_eol();
21687 catchup=false;
21688 }
21689
21690
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 box_out("Reading DMaps...");
21691
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 ret=readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS);
21692
1/9
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
565 checkstatus(ret);
21693
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 box_out("okay.");
21694
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 box_eol();
21695 565 break;
21696
21697 case ID_DOORS:
21698
21699 //door combo sets
21700
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 565 times.
565 if(catchup)
21701 {
21702 box_out("found.");
21703 box_eol();
21704 catchup=false;
21705 }
21706
21707
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 box_out("Reading Doors...");
21708
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 ret=readdoorcombosets(f, &tempheader);
21709
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 565 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
565 checkstatus(ret);
21710
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 box_out("okay.");
21711
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 box_eol();
21712 565 break;
21713
21714 case ID_ITEMS:
21715
21716 //items
21717
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 565 times.
565 if(catchup)
21718 {
21719 box_out("found.");
21720 box_eol();
21721 catchup=false;
21722 }
21723
21724
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 box_out("Reading Items...");
21725
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 ret=readitems(f, tempheader.zelda_version, tempheader.build);
21726
1/9
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
565 checkstatus(ret);
21727
21728
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 box_out("okay.");
21729
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 box_eol();
21730 565 break;
21731
21732 case ID_WEAPONS:
21733
21734 //weapons
21735
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 565 times.
565 if(catchup)
21736 {
21737 box_out("found.");
21738 box_eol();
21739 catchup=false;
21740 }
21741
21742
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 box_out("Reading Weapons...");
21743
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 ret=readweapons(f, &tempheader);
21744
1/9
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
565 checkstatus(ret);
21745
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 box_out("okay.");
21746
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 box_eol();
21747 565 break;
21748
21749 case ID_COLORS:
21750
21751 //misc. colors
21752
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 526 times.
526 if(catchup)
21753 {
21754 box_out("found.");
21755 box_eol();
21756 catchup=false;
21757 }
21758
21759
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 box_out("Reading Misc. Colors...");
21760
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 ret=readmisccolors(f, &tempheader, Misc);
21761
1/9
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
526 checkstatus(ret);
21762
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 box_out("okay.");
21763
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 box_eol();
21764 526 break;
21765
21766 case ID_ICONS:
21767
21768 //game icons
21769
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 526 times.
526 if(catchup)
21770 {
21771 box_out("found.");
21772 box_eol();
21773 catchup=false;
21774 }
21775
21776
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 box_out("Reading Game Icons...");
21777
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 ret=readgameicons(f, &tempheader, Misc);
21778
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 526 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
526 checkstatus(ret);
21779
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 box_out("okay.");
21780
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 box_eol();
21781 526 break;
21782
21783 case ID_INITDATA:
21784
21785 //initialization data
21786
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 565 times.
565 if(catchup)
21787 {
21788 box_out("found.");
21789 box_eol();
21790 catchup=false;
21791 }
21792
21793
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 box_out("Reading Init. Data...");
21794
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 ret=readinitdata(f, &tempheader);
21795
1/9
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
565 checkstatus(ret);
21796
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 box_out("okay.");
21797
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 box_eol();
21798
21799
2/4
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 565 times.
565 if(!get_bit(skip_flags, skip_subscreens))
21800 {
21801
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 503 times.
565 if(subscr_mode!=ssdtMAX) //not using custom subscreens
21802 {
21803
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 setupsubscreens();
21804
21805
2/2
✓ Branch 0 taken 31744 times.
✓ Branch 1 taken 62 times.
31806 for(int32_t i=0; i<MAXDMAPS; ++i)
21806 {
21807 31744 int32_t type=DMaps[i].type&dmfTYPE;
21808
2/2
✓ Branch 0 taken 687 times.
✓ Branch 1 taken 31057 times.
31744 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
21809 31744 DMaps[i].passive_subscreen=(get_qr(qr_ENABLEMAGIC))?0:1;
21810 31744 }
21811 62 }
21812 565 }
21813
21814
2/4
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 565 times.
565 if(!get_bit(skip_flags, skip_sfx))
21815 {
21816 565 setupsfx();
21817 565 }
21818
21819
2/4
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 565 times.
✗ Branch 3 not taken.
565 if(!get_bit(skip_flags, skip_itemdropsets))
21820 {
21821
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 init_item_drop_sets();
21822 565 }
21823
21824
2/4
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 565 times.
565 if(!get_bit(skip_flags, skip_favorites))
21825 {
21826 565 init_favorites();
21827 565 }
21828
21829 565 break;
21830
21831 case ID_GUYS:
21832
21833 //guys
21834
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 565 times.
565 if(catchup)
21835 {
21836 box_out("found.");
21837 box_eol();
21838 catchup=false;
21839 }
21840
21841
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 box_out("Reading Custom Guy Data...");
21842
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 ret=readguys(f, &tempheader);
21843
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 565 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
565 checkstatus(ret);
21844
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 box_out("okay.");
21845
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 box_eol();
21846 565 break;
21847
21848 case ID_HEROSPRITES:
21849
21850 //player sprites
21851
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 526 times.
526 if(catchup)
21852 {
21853 box_out("found.");
21854 box_eol();
21855 catchup=false;
21856 }
21857
21858
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 box_out("Reading Custom Player Sprite Data...");
21859
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 ret=readherosprites(f, &tempheader);
21860
1/9
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
526 checkstatus(ret);
21861
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 box_out("okay.");
21862
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 box_eol();
21863 526 break;
21864
21865 case ID_SUBSCREEN:
21866
21867 //custom subscreens
21868
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 526 times.
526 if(catchup)
21869 {
21870 box_out("found.");
21871 box_eol();
21872 catchup=false;
21873 }
21874
21875
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 box_out("Reading Custom Subscreen Data...");
21876
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 ret=readsubscreens(f);
21877
1/9
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
526 checkstatus(ret);
21878
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 box_out("okay.");
21879
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 box_eol();
21880 526 break;
21881
21882 case ID_FFSCRIPT:
21883
21884 //Freeform combo scripts
21885
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 526 times.
526 if(catchup)
21886 {
21887 box_out("found.");
21888 box_eol();
21889 catchup=false;
21890 }
21891
21892
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 box_out("Reading FF Script Data...");
21893
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 ret=readffscript(f, &tempheader);
21894
1/9
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
526 checkstatus(ret);
21895
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 box_out("okay.");
21896
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 box_eol();
21897 526 break;
21898
21899 case ID_SFX:
21900
21901 //SFX data
21902
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 526 times.
526 if(catchup)
21903 {
21904 box_out("found.");
21905 box_eol();
21906 catchup=false;
21907 }
21908
21909
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 box_out("Reading SFX Data...");
21910
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 ret=readsfx(f, &tempheader);
21911
1/9
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
526 checkstatus(ret);
21912
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 box_out("okay.");
21913
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 box_eol();
21914 526 break;
21915
21916 case ID_MIDIS:
21917
21918 //midis
21919
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 565 times.
565 if(catchup)
21920 {
21921 box_out("found.");
21922 box_eol();
21923 catchup=false;
21924 }
21925
21926
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 box_out("Reading Tunes...");
21927
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 ret=readtunes(f, &tempheader, tunes);
21928
1/9
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
565 checkstatus(ret);
21929
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 box_out("okay.");
21930
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 box_eol();
21931 565 break;
21932
21933 case ID_CHEATS:
21934
21935 //cheat codes
21936
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 565 times.
565 if(catchup)
21937 {
21938 box_out("found.");
21939 box_eol();
21940 catchup=false;
21941 }
21942
21943
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 box_out("Reading Cheat Codes...");
21944
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 ret=readcheatcodes(f, &tempheader);
21945
1/9
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
565 checkstatus(ret);
21946
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 box_out("okay.");
21947
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 box_eol();
21948 565 break;
21949
21950 case ID_ITEMDROPSETS:
21951
21952 //item drop sets
21953
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 526 times.
526 if(catchup)
21954 {
21955 box_out("found.");
21956 box_eol();
21957 catchup=false;
21958 }
21959
21960
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 box_out("Reading Item Drop Sets...");
21961
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 ret=readitemdropsets(f, tempheader.zelda_version, tempheader.build);
21962
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 526 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
526 checkstatus(ret);
21963
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 box_out("okay.");
21964
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 box_eol();
21965 526 break;
21966
21967 case ID_FAVORITES:
21968
21969 //favorite combos and combo aliases
21970
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 526 times.
526 if(catchup)
21971 {
21972 box_out("found.");
21973 box_eol();
21974 catchup=false;
21975 }
21976
21977
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 box_out("Reading Favorite Combos...");
21978
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 ret=readfavorites(f, tempheader.zelda_version, tempheader.build);
21979
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 526 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
526 checkstatus(ret);
21980
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 box_out("okay.");
21981
1/2
✓ Branch 0 taken 526 times.
✗ Branch 1 not taken.
526 box_eol();
21982 526 break;
21983
21984 default:
21985 if(!catchup)
21986 {
21987 box_out("Bad token! Searching...");
21988 box_eol();
21989 }
21990
21991 catchup=true;
21992 break;
21993 }
21994
21995
21996
1/2
✓ Branch 0 taken 13209 times.
✗ Branch 1 not taken.
13209 if(catchup)
21997 {
21998 //section id
21999 section_id=(section_id<<8);
22000
22001 if(!p_getc(&tempbyte,f))
22002 {
22003 goto invalid;
22004 }
22005
22006 section_id+=tempbyte;
22007 }
22008
22009 else
22010 {
22011 //section id
22012
3/4
✓ Branch 0 taken 13209 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12644 times.
✓ Branch 3 taken 565 times.
13209 if(!pack_feof(f))
22013 {
22014
2/4
✓ Branch 0 taken 12644 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12644 times.
✗ Branch 3 not taken.
12644 if(!p_mgetl(&section_id,f))
22015 {
22016 goto invalid;
22017 }
22018 12644 }
22019 }
22020 }
22021
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 565 times.
565 }
22022 else
22023 {
22024
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 std::vector<std::tuple<std::string, int32_t, std::function<int32_t()>>> hardcoded_sections = {
22025
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Rules", ID_RULES, [&](){ return readrules(f, &tempheader); }},
22026
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Strings", ID_STRINGS, [&](){ return readstrings(f, &tempheader); }},
22027
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Doors", ID_DOORS, [&](){ return readdoorcombosets(f, &tempheader); }},
22028
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "DMaps", ID_DMAPS, [&](){ return readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS); }},
22029
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Misc. Data", ID_MISC, [&](){ return readmisc(f, &tempheader, Misc); }},
22030
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Items", ID_ITEMS, [&](){ return readitems(f, tempheader.zelda_version, tempheader.build); }},
22031
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Weapons", ID_WEAPONS, [&](){ return readweapons(f, &tempheader); }},
22032
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Custom Guy Data", ID_GUYS, [&](){ return readguys(f, &tempheader); }},
22033
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Maps", ID_MAPS, [&](){ return readmaps(f, &tempheader); }},
22034
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Combos", ID_COMBOS, [&](){ return readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS); }},
22035
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Color Data", ID_CSETS, [&](){ return readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL); }},
22036
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Tiles", ID_TILES, [&](){ return readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false); }},
22037
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Tunes", ID_MIDIS, [&](){ return readtunes(f, &tempheader, tunes); }},
22038
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Cheat Codes", ID_CHEATS, [&](){ return readcheatcodes(f, &tempheader); }},
22039
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Init. Data", ID_INITDATA, [&](){ return readinitdata(f, &tempheader); }},
22040
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Custom Player Sprite Data", ID_HEROSPRITES, [&](){ return readherosprites2(f, -1, 0); }},
22041
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Up Default Item Drop Sets", ID_ITEMDROPSETS, [&](){ return readitemdropsets(f, -1, 0); }},
22042 };
22043
22044 24 legacy_skip_flags = skip_flags;
22045
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 408 times.
1250 for (auto& [desc, section_id, fn] : hardcoded_sections)
22046 {
22047
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 int section_enum = section_id_to_enum(section_id);
22048
2/4
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 408 times.
✗ Branch 3 not taken.
408 bool skip = section_enum >= 0 && get_bit(skip_flags, section_enum);
22049
2/2
✓ Branch 0 taken 392 times.
✓ Branch 1 taken 16 times.
408 if (skip)
22050 {
22051 // Nothing to read.
22052
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 15 times.
16 if (section_id == ID_RULES)
22053 1 continue;
22054
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 14 times.
15 if (section_id == ID_GUYS)
22055 1 continue;
22056
22057 // Haven't looked at how to skip these, because we don't need to currently: the only
22058 // usage of skip_flags currently is all off except: header and tiles (see `load_imagebuf`).
22059
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 13 times.
14 if (section_id == ID_MIDIS)
22060 1 continue;
22061
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 12 times.
13 if (section_id == ID_CHEATS)
22062 1 continue;
22063
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 11 times.
12 if (section_id == ID_INITDATA)
22064 1 continue;
22065
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 10 times.
11 if (section_id == ID_HEROSPRITES)
22066 1 continue;
22067
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 9 times.
10 if (section_id == ID_ITEMDROPSETS)
22068 1 continue;
22069 9 }
22070
22071 // Would be nice, but old sections mostly did not save section sizes. We could advance by
22072 // a specific amount, but it'd be a lot of work to get it right. So, for old quests, let's just
22073 // read all the sections even if requested to skip some.
22074 // if (int retval = maybe_skip_section(f, section_id, skip_flags); retval != qe_OK)
22075 // {
22076 // if (retval == qe_cancel)
22077 // continue;
22078 // checkstatus(retval);
22079 // }
22080
22081
3/6
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 401 times.
✗ Branch 5 not taken.
802 box_out(fmt::format("Reading {}...", desc).c_str());
22082
1/2
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
401 ret = fn();
22083
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
401 checkstatus(ret);
22084
1/2
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
401 box_out("okay.");
22085
1/2
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
401 box_eol();
22086 }
22087 24 legacy_skip_flags = nullptr;
22088
22089
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 1 times.
24 if(!get_bit(skip_flags, skip_subscreens))
22090 {
22091
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 setupsubscreens();
22092
22093
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 23 times.
11799 for(int32_t i=0; i<MAXDMAPS; ++i)
22094 {
22095 11776 int32_t type=DMaps[i].type&dmfTYPE;
22096
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 11732 times.
11776 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
22097 11776 DMaps[i].passive_subscreen=(get_qr(qr_ENABLEMAGIC))?0:1;
22098 11776 }
22099 23 }
22100
22101
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 box_out("Setting Up Default Sound Effects...");
22102
22103
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 23 times.
24 if(!get_bit(skip_flags, skip_sfx))
22104 23 setupsfx();
22105
22106
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 23 times.
24 if(!get_bit(skip_flags, skip_favorites))
22107 23 init_favorites();
22108
22109
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 box_out("okay.");
22110
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 box_eol();
22111
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
24 }
22112
22113 589 init_spritelists();
22114
22115 // check data
22116
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 589 times.
589 if(f)
22117 {
22118 589 pack_fclose(f);
22119 589 }
22120 589 clear_quest_tmpfile();
22121
22122
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 589 times.
589 if(!oldquest)
22123 {
22124
1/2
✓ Branch 0 taken 589 times.
✗ Branch 1 not taken.
589 if(exists(tmpfilename))
22125 {
22126 delete_file(tmpfilename);
22127 }
22128 589 }
22129
22130
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 589 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
589 if(fixffcs && combosread && mapsread)
22131 {
22132 for(int32_t i=0; i<map_count; i++)
22133 {
22134 for(int32_t j=0; j<MAPSCRS; j++)
22135 {
22136 for(int32_t m=0; m<32; m++)
22137 {
22138 if(combobuf[TheMaps[(i*MAPSCRS)+j].ffcs[m].data].type == cCHANGE)
22139 TheMaps[(i*MAPSCRS)+j].ffcs[m].flags|=ffCHANGER;
22140 }
22141 }
22142 }
22143 }
22144
22145
5/6
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 533 times.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 55 times.
✗ Branch 5 not taken.
589 if(get_qr(qr_CONTFULL_DEP) && !get_bit(skip_flags, skip_rules) && !get_bit(skip_flags, skip_initdata))
22146 {
22147 55 set_qr(qr_CONTFULL_DEP, 0);
22148 55 zinit.flags.set(INIT_FL_CONTPERCENT,true);
22149 55 zinit.cont_heart=100;
22150 55 zinit.counter[crLIFE]=zinit.mcounter[crLIFE];
22151 55 }
22152
22153 589 box_out("Done.");
22154 589 box_eol();
22155 589 box_end(false);
22156
22157
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 589 times.
589 if(!get_bit(skip_flags, skip_header))
22158 {
22159 589 memcpy(Header, &tempheader, sizeof(tempheader));
22160 589 }
22161
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 588 times.
589 if(!get_bit(skip_flags, skip_zinfo))
22162 {
22163 588 ZI.copyFrom(tempzi);
22164 588 }
22165
22166
2/2
✓ Branch 0 taken 588 times.
✓ Branch 1 taken 1 times.
589 if(get_bit(skip_flags, skip_maps))
22167 {
22168 1 map_count=old_map_count;
22169 1 }
22170
22171
2/2
✓ Branch 0 taken 588 times.
✓ Branch 1 taken 1 times.
589 if(get_bit(skip_flags, skip_rules))
22172 {
22173 1 memcpy(quest_rules, old_quest_rules, QUESTRULES_NEW_SIZE);
22174 1 memcpy(extra_rules, old_extra_rules, EXTRARULES_SIZE);
22175 1 unpack_qrs();
22176 1 }
22177
22178
2/2
✓ Branch 0 taken 588 times.
✓ Branch 1 taken 1 times.
589 if(get_bit(skip_flags, skip_midis))
22179 {
22180 1 memcpy(midi_flags, old_midi_flags, MIDIFLAGS_SIZE);
22181 1 }
22182
22183
2/2
✓ Branch 0 taken 565 times.
✓ Branch 1 taken 24 times.
589 if( FFCore.quest_format[vZelda] < 0x210 )
22184 {
22185 24 zprint2("\n[QUEST METADATA]\n");
22186
22187
3/13
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 6 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
24 switch(FFCore.quest_format[vZelda])
22188 {
22189 case 0x193:
22190 {
22191 zprint2("Last saved in version: 1.93, Beta %d\n", FFCore.quest_format[vBuild]); break;
22192 }
22193 case 0x192:
22194 {
22195 6 zprint2("Last saved in version: 1.92, Beta %d\n", FFCore.quest_format[vBuild]); break;
22196 }
22197 case 0x190:
22198 {
22199 12 zprint2("Last saved in version: 1.90");
22200
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22201 12 else zprint2("\n");
22202 12 break;
22203 }
22204 case 0x188:
22205 {
22206 zprint2("Last saved in version: 1.88");
22207 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22208 else zprint2("\n");
22209 break;
22210 }
22211 case 0x187:
22212 {
22213 zprint2("Last saved in version: 1.87");
22214 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22215 else zprint2("\n");
22216 break;
22217 }
22218 case 0x186:
22219 {
22220 zprint2("Last saved in version: 1.86");
22221 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22222 else zprint2("\n");
22223 break;
22224 }
22225 case 0x185:
22226 {
22227 zprint2("Last saved in version: 1.85");
22228 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22229 else zprint2("\n");
22230 break;
22231 }
22232 case 0x184:
22233 {
22234 6 zprint2("Last saved in version: 1.84");
22235
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22236 6 else zprint2("\n");
22237 6 break;
22238 }
22239 case 0x183:
22240 {
22241 zprint2("Last saved in version: 1.83");
22242 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22243 else zprint2("\n");
22244 break;
22245 }
22246 case 0x182:
22247 {
22248 zprint2("Last saved in version: 1.82");
22249 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22250 else zprint2("\n");
22251 break;
22252 }
22253 case 0x181:
22254 {
22255 zprint2("Last saved in version: 1.81");
22256 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22257 else zprint2("\n");
22258 break;
22259 }
22260 case 0x180:
22261 {
22262 zprint2("Last saved in version: 1.80");
22263 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22264 else zprint2("\n");
22265 break;
22266 }
22267 default:
22268 {
22269 zprint2("Last saved in version: %x, Beta %d\n", FFCore.quest_format[vZelda],FFCore.quest_format[vBuild]); break;
22270 }
22271 }
22272 24 }
22273
22274
1/2
✓ Branch 0 taken 589 times.
✗ Branch 1 not taken.
589 if(loading_tileset_flags & TILESET_CLEARMAPS)
22275 {
22276 TheMaps.clear();
22277 TheMaps.resize(MAPSCRS*1);
22278 map_count = 1;
22279 map_autolayers.clear();
22280 map_autolayers.resize(6*1);
22281 for(size_t i = 0; i < MAPSCRS; ++i)
22282 {
22283 TheMaps[i].zero_memory();
22284 }
22285 }
22286
1/2
✓ Branch 0 taken 589 times.
✗ Branch 1 not taken.
589 if(loading_tileset_flags & TILESET_CLEARHEADER)
22287 {
22288 memset(Header->password, 0, sizeof(Header->password));
22289 memset(Header->minver, 0, sizeof(Header->minver));
22290 memset(Header->title, 0, sizeof(Header->title));
22291 memset(Header->author, 0, sizeof(Header->author));
22292 memset(Header->version, 0, sizeof(Header->version));
22293 Header->use_keyfile = 0;
22294 Header->dirty_password = false;
22295 cvs_MD5Context ctx;
22296 cvs_MD5Init(&ctx);
22297 cvs_MD5Update(&ctx, (const uint8_t*)"", 0);
22298 cvs_MD5Final(Header->pwd_hash, &ctx);
22299 }
22300
22301 589 return qe_OK;
22302
22303 invalid:
22304 // TODO: It's too easy to forget to jump to this label, and accidentally leave the file open.
22305 // Should wrap PACKFILE in a std::unique_pointer with a custom deallocator.
22306 box_out("error.");
22307 box_eol();
22308 box_end(true);
22309
22310 pack_fclose(f);
22311
22312 if(!oldquest)
22313 {
22314 if(exists(tmpfilename))
22315 {
22316 delete_file(tmpfilename);
22317 }
22318 }
22319
22320 return qe_invalid;
22321
22322 589 }
22323
22324 static bool _is_loading_quest;
22325
22326 bool is_loading_quest()
22327 {
22328 return _is_loading_quest;
22329 }
22330
22331 589 int32_t loadquest(const char *filename, zquestheader *Header, miscQdata *Misc,
22332 zctune *tunes, bool show_progress, byte *skip_flags, byte printmetadata,
22333 bool report, byte qst_num, dword tilesetflags)
22334 {
22335 589 loading_tileset_flags = tilesetflags;
22336 589 const char* basename = get_filename(filename);
22337 589 zapp_reporting_add_breadcrumb("load_quest", basename);
22338 589 zapp_reporting_set_tag("qst.filename", basename);
22339
22340 589 loading_qst_name = filename;
22341 589 loading_qst_num = qst_num;
22342 // In CI, builds are cached for replay tests, which can result in their build dates being earlier than what it would be locally.
22343 // So to avoid a more-recently updated .qst file from hitting the "last saved in a newer version" prompt, we disable in CI.
22344
1/2
✓ Branch 0 taken 589 times.
✗ Branch 1 not taken.
589 if (!is_ci())
22345 loadquest_report = report;
22346
22347 589 _is_loading_quest = true;
22348 589 auto start = std::chrono::steady_clock::now();
22349 589 int32_t ret = _lq_int(filename, Header, Misc, tunes, show_progress, skip_flags, printmetadata);
22350 589 int32_t load_ms = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - start).count();
22351 589 zprint2("Time to load qst: %d ms\n", load_ms);
22352 589 _is_loading_quest = false;
22353
22354
2/2
✓ Branch 0 taken 588 times.
✓ Branch 1 taken 1 times.
589 if(show_progress)
22355 {
22356
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(ret)
22357 {
22358 box_out("-- Error loading quest file! --");
22359 box_end(true);
22360 }
22361 1 else box_end(false);
22362 1 }
22363
22364 589 load_tmp_zi = NULL;
22365 589 loading_qst_name = NULL;
22366 589 loadquest_report = false;
22367 589 loading_qst_num = 0;
22368
22369 589 zapp_reporting_set_tag("qst.author", Header->author);
22370 589 zapp_reporting_set_tag("qst.title", Header->title);
22371 589 zapp_reporting_set_tag("qst.zc_version", Header->getVerStr());
22372
22373 589 return ret;
22374 }
22375